How sort elements and store them in a variable, XSLT

后端 未结 3 1493
不思量自难忘°
不思量自难忘° 2021-01-20 19:59

I was wondering whether it\'s possible to sort some elements first and store them (already sorted) in a variable. I would need to refer to them thought XSLT that\'s why I\'d

3条回答
  •  天命终不由人
    2021-01-20 20:39

    Firstly, in your variable declaration, you do need to do something to create new nodes. Strictly speaking, you are not sorting them, but just reading through them in a given order. I think you need to add some sort of xsl:copy command.

     
       
         
         
         
        
      
     
    

    What this creates is a 'node-set', but to access it you will need to make use of an extension function in XSLT. Which one you use depends on the XSLT processor you are using. In the example I am about to give, I am using the Microsoft one.

     
    

    Then, to access the nodes in your variable, you can do something like this

    
    

    Here is a good article to read up on node-sets

    Xml.com article on Node-Sets

提交回复
热议问题