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 547
醉酒成梦
醉酒成梦 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 08:04

    There is no runtime evaluation for XPath expression in standar XSLT 1.0

    So, depending what is $inputid, you could have different solutions.

    But this /root/meta/url_params/$inputid is wrong because right hand of / must be a relative path in XPath 1.0 (in XPath 2.0 can be a function call, also).

    For this particulary case you can use:

    /root/meta/url_params/*[name()=$inputid]
    

    or

    /root/meta/url_params/*[@id=$inputid]
    

    For a general case, I will go with walker pattern like Dimitre's answer.

提交回复
热议问题