How to organize entries of XML

后端 未结 2 1392
遇见更好的自我
遇见更好的自我 2021-01-26 00:58

XML:



    

        
2条回答
  •  攒了一身酷
    2021-01-26 01:47

    It is better if you structure your XML like this (omitted unused fields for brevity):

    
    
      
        Link #2
        2
      
      
        Link #1
        1
      
      
        Link #3
        3
      
    
    

    Your XSLT then becomes:

    
    
    
      
        
      
    
    

    I've also modified the data-toggle (I assume it's Bootstrap) to name the class it should toggle (collapse as an example), and the data-target to use generate-id(), which you should use when generating the content to be acted upon.

    The XML resulting from the above is this:

    
    
    

    If you need to set attributes on the first element in the xsl:for-each, you can use this in the XSLT:

    
        
        
  • setCurrent
  • and similar for the .

提交回复
热议问题