How to replace a tag with another tag in xml using xsl

前端 未结 2 1397
予麋鹿
予麋鹿 2021-01-02 23:40

My xml file looks like below.

  
  86
  100
  1.0
           


        
2条回答
  •  孤独总比滥情好
    2021-01-03 00:27

    This transformation:

    
     
     
    
     
      
       
      
     
    
     
      
     
    
     
      
       86_1.0
     
    
    

    when applied on the provided XML document:

    
        86
        100
        1.0
        1.0
    
    

    produces the wanted, correct result:

    
       86
       100
       1.0
       1.0
       86_1.0
    
    

    Explanation:

    1. Using and overriding the identity rule/template -- the most fundamental and powerful XSLT design pattern.

    2. Override on any element named name and creating an element named brlName (rename).

    3. Override on the last last element child of the top element. Calling the identity rule by name for this node (copying) and then creating an element named drlName with a specific text-node child as per the requirements.

    Using and overriding the identity rule/template is the most fundamental and powerful XSLT design pattern. You can learn more about it here.

提交回复
热议问题