我有一个关于XSLT的问题,基本上我有一些转换要做,但最后,我希望在一个xslt:变量中完成所有的转换。
基本上,我的意思是类似于这样的东西,当然xslt会更复杂,但是为了说明我的意思是:
<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>使用这种xslt,我想让general_variable看起来像这样:
<process name="somename">
</process>
...
<task name="somename">
</task>
...这是可行的还是不可能的?
发布于 2013-09-12 09:45:30
是的,您可以以这种方式在变量中捕获任何处理的结果。
但是,在XSLT1.0中,对于如何使用结果变量有一些限制:它被称为结果树片段。如果您想以任何有趣的方式处理它,您将需要exslt:node-set()扩展将其转换为常规文档树。在XSLT2.0中,这个限制被删除了。
https://stackoverflow.com/questions/18756762
复制相似问题