In XSLT, how come I can't set the select-attribute of a value-of using xsl:attribute, and what's a good alternative?

后端 未结 2 548
醉酒成梦
醉酒成梦 2021-01-20 07:29

I have a constant and a variable that I wann mouch together to select a specific node, this is what I want to do:


 

        
2条回答
  •  自闭症患者
    2021-01-20 07:49

    While @Alejandro is right that in the general case dynamic evaluation will be needed (and this may be provided in XSLT 2.1+), there are manageable simpler cases.

    For example, if $inputid contains just a name, you probably want this:

    
    

    We can implement a rather general dynamic XPath evaluator if we only restrict each location path to be an element name:

    
     
    
     
    
     
    
     
      : 
    
      
        
      
     
    
     
       
       
    
       
        
          
        
        
          
            
            
          
        
       
     
    
    

    when this transformation is applied on this XML document:

    
      
        
          
            
              5
            
          
          
            
              8
            
          
        
      
    
    

    the wanted, correct result is produced:

    root/meta/url_params/param/yyy/value: 8
    

提交回复
热议问题