Create node set and pass as a parameter

后端 未结 2 662
清歌不尽
清歌不尽 2020-12-01 10:51

Using XSLT 1.0, I\'m trying to essentially create a small node set and then pass it as a parameter to a template, something like the following:



        
2条回答
  •  -上瘾入骨i
    2020-12-01 11:03

    There is a way (non-standard) in XSLT 1.0 to create temporary trees dynamically and evaluate XPath expressions on them, however this requires using the xxx:node-set() function.

    Whenever nodes are dynamically created inside the body of an xsl:variable or an xsl:param, the type of that xsl:variable / xsl:param is RTF (Result Tree Fragment) and the W3 XSLT 1.0 Spec. limits severyly the kind of XPath expressions that can be evaluated against an RTF.

    As a workaround, almost every XSLT 1.0 vendor has their own xxx:node-set() extension function that takes an RTF and produces a normal node-set from it.

    The namespace to which the xxx prefix (or any other prefix you choose) is bound is different for different vendors. For MSXML and the two .NET XSLT processor it is: "urn:schemas-microsoft-com:xslt". The EXSLT library uses the namespace: "http://exslt.org/common". This namespace EXSLT is implemented on many XSLT 1.0 processors and it is recommended to use its xxx:node-set() extension, if possible.

    Here is a quick example:

    
     
      
       
        
       
      
    
      
     
    
    

提交回复
热议问题