In XSLT how do I increment a global variable from a different scope?

后端 未结 8 1114
礼貌的吻别
礼貌的吻别 2020-11-29 04:41

I am processing an XML file where I want to keep count of the number of nodes, so that I can use it as an ID as I write new nodes.

At the moment I have a global vari

8条回答
  •  心在旅途
    2020-11-29 05:12

    XSLT variables cannot be changed. You'll have pass the value along from template to template.

    If you are using XSLT 2.0, you can have parameters and use tunneling to propagate the variable to the right templates.

    Your template will look something like this:

    
    
      
         
      
    
    

    Also look at using generate-id() if you want to create ids.

提交回复
热议问题