Trouble matching XML elements that has namespace attribute

后端 未结 2 458
小蘑菇
小蘑菇 2021-01-23 22:57

How would the conditional statement look like if I\'m to insert a section of text into the xml below using xslt?



        
2条回答
  •  无人及你
    2021-01-23 23:35

    A better, and more elegant, way to solve this would be to use a prefix for your namespace. I prefer working with a null default namespace and using prefixes for all defined namespaces.

    Matching on fn:local-name() would match on the local name of the node in all namespaces. All that's needed in your matching condition if using a prefix for your namespace is my:item[last()].

    Input:

    
    
      
        
      
      
        
      
    
    

    XSLT:

    
      
    
      
        
        
          
          
        
      
    
      
        
          
        
      
    
      
        
        
      
    
    
    

    Output:

    
    
      
        
      
      
        
      
      
        
        
      
    
    

提交回复
热议问题