Converting XML elements to XML attributes using XSLT

前端 未结 5 1783
梦谈多话
梦谈多话 2020-12-03 00:00

We have a current system that outputs an XML file which is in the following format:


   
      something<         


        
5条回答
  •  日久生厌
    2020-12-03 00:32

    Here is probably the simplest solution that will convert any children-elements of ITEM to its attributes and will reproduce everything else as is, while converting the element names to any desired attribute names:

    
     
     
      
    
      
        
        
        
      
      
      
     
    
      
        
          
        
      
     
      
        
          
        
      
    
    

    when the above transformation is applied on the provided XML document:

    
        
            something
            something
            something
        
    
    

    the wanted result is produced:

    
       
    
    

    Do note the following:

    1. The use of the identity rule

    2. The use of

    3. The use of the variable vrtfNameMapping without any xxx:node-set() extension function.

    4. The fact that we handle any mapping between a name and a newName, not only simple lower-casing.

提交回复
热议问题