Reputation: 2655
I have a question regarding the XSLT, basically I have some transformation to do, but at the end i would like to have all the transformations i've done inside one xslt:variable.
Basically what i mean is something like this, of course the xslt will be more complex, but just to illustrate what i mean is following:
<xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x="http://www.w3.org/2001/XMLSchema">
<xsl:output method="html" indent="no"/>
<xsl:decimal-format NaN=""/>
<xsl:template match="/">
<xsl:call-template name="base_template"/>
</xsl:template>
<xsl:template name="base_template">
<!-- This is what i mean -->
<xsl:variable name="general_variale">
<xsl:call-template name="template_three" />
<br />
<xsl:call-template name="template_two" />
<br />
<xsl:call-template name="template_one" />
</xsl:variable>
</xsl:template>
<xsl:template name="template_three">
<xsl:for-each select="$Rows">
<xsl:variable name="id" select="@ID" />
<xsl:for-each select="$filteredRows_Releases">
<process name="$id">
....
</process>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template name="template_two">
<xsl:for-each select="$Rows">
<xsl:variable name="id" select="@ID" />
<xsl:for-each select="$filteredRows_Releases">
<task name="$id">
....
</task>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
With this xslt i would like to have a general_variable look somethink like this:
<process name="somename">
</process>
...
<task name="somename">
</task>
...
Will this work or it isn't possible?
Upvotes: 1
Views: 639
Reputation: 163342
Yes, you can capture the result of any processing in a variable in this way.
However, in XSLT 1.0 there are restrictions on how you can use the resulting variable: it's known as a result tree fragment. If you want to process it in any interesting ways, you will need the exslt:node-set() extension to convert it to a regular document tree. In XSLT 2.0 this restriction is removed.
Upvotes: 1