Can you transform unordered xml to match an xsd:sequence order?

后端 未结 2 802
灰色年华
灰色年华 2020-12-18 11:50

Hi i need to transform unorderd xml using xslt to the correct order as specified in an xsd schema


    

        
2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-18 12:29

    This may not be the best way, but it seems to work ok. I'm not sure if the order that the xs:element's are processed is guaranteed though. Also, this is an XSLT 2.0 answer tested with Saxon-HE 9.3.0.5 in oXygen.

    XML Input (modified the case of Person to match the schema):

    
      
      
      
    
    

    External XSD Schema file (schema.xsd):

    
      
        
          
            
            
            
          
        
      
    
    

    XSLT 2.0 Stylesheet:

    
      
      
    
      
        
      
    
      
        
        
        
          
            
            
              
            
                
        
      
    
    
    

    XML Output:

    
       1234567890
       The BFG
       
    5

    Hope this helps.

提交回复
热议问题