开发者

variable inside a variable in xslt coding [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
开发者_JS百科

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 3 years ago.

Improve this question

Is it possible to create a variable inside a variable in xslt??

Is the above thing possible???


Is this what you mean?

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" version="2.0">

  <xsl:variable name="a">
    <xsl:variable name="b" select="10"/>
    <xsl:value-of select="$b"/>
  </xsl:variable>

  <xsl:template match="/">
    <xsl:value-of select="$a"/>
  </xsl:template>

</xsl:stylesheet>

The answer is yes, but the inner variable is in scope only within the definition of the outer variable. So if the definition of the outer variable calls for some complex expression that you'd like to store in a temporary (possibly for debugging purposes), then this is a way to do it.


The answer is: yes. This stylesheet:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text"/>
    <xsl:template match="/">
        <xsl:variable name="vOuter">
            <xsl:variable name="vInner">
                <xsl:value-of select="'Content'"/>
            </xsl:variable>
            <xsl:value-of select="concat('Some ',$vInner)"/>
        </xsl:variable>
        <xsl:value-of select="$vOuter"/>
    </xsl:template>
</xsl:stylesheet>

Output:

Some Content
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜