Why aren't my XSLT variables substituting their values?

前端 未结 6 1127
暖寄归人
暖寄归人 2020-12-11 06:00

I am trying to use XSLT variables and not having much success, hopefully I\'m just doing something dumb.

I have the following code snippet:



        
6条回答
  •  庸人自扰
    2020-12-11 06:51

    @lwburk's answer is great (+1), but the last question/answer is only accurate for XSLT 1.0 and 2.0. In 3.0 you can use a TVT (Text Value Template; similar to the AVT (Attribute Value Template) mentioned in @lwburk's answer).

    To use a TVT, add the standard attribute xsl:expand-text="yes" to the element. This will cause the processor to treat descendant text nodes of that element as a TVT.

    Example:

    XSLT 3.0

    
        
    
        
            
            
            This is {$who}'s result: {$what}
        
    
    
    

    Output (using any well-formed XML as input)

    This is Dan's result: BAM!
    

    Note: Tested using Saxon-PE 9.5.

提交回复
热议问题