XSLT Bitwise Logic

前端 未结 4 1727
失恋的感觉
失恋的感觉 2020-12-03 15:45

I have an existing data set that utilizes an integer to store multiple values; the legacy front end did a simple bitwise check (e.g. in C#: iValues & 16 == 16) to see if

4条回答
  •  既然无缘
    2020-12-03 16:36

    XSLT does not define bitwise operations. If you want them, you have to roll your own.

    If you're using XSLT specifically in .NET 2.0 context - that is, XslCompiledTransform class - then the simplest solution is to use a scripting block to introduce a C# function that does it, and then just call that:

    
    
      
      
      
    
      ...
    
      
      
      ...
    
    
    

    Or you can define the more high-level primitives in a scripting block, such as HasFlag, and then use those.

    When loading such a stylesheet, you will need to explicitly enable scripting in it:

    XslCompiledTransform xslt = new XslCompiledTransform();
    xslt.Load("foo.xsl",
      new XsltSettings { EnableScript = true },
      new XmlUrlResolver());
    

提交回复
热议问题