问候,
我正在寻找一种在 XSLT 中进行内联结果(输出)文档选择的方法。我知道创建一个xsl:result-document
节点以将一个转换应用于多个文档的方法。通常这种方法使用几个pass,例如:
<xsl:template match="/">
<xsl:apply-templates select="*"/>
<xsl:result-document href="test.xml">
<xsl:apply-templates select="*"/>
</xsl:result-document>
</xsl:template>
我正在寻找一种内联方法,这样我就可以一次构建两个输出文档。原因是我有一个临时树,它是在运行转换时构建的,我想输出到文件中。
<xsl:variable name="treeBase">
<Base/>
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="these_elements">
<xsl:param name="temp" select="$treeBase"/>
</xsl:template>
<xsl:template match="not_these_elements">
<xsl:param name="temp" select="$treeBase"/>
<xsl:apply-templates select="@*|node()">
<xsl:with-param name="temp">
<Base>
<xsl:copy-of select="$temp/Base/*"/>
<Item>
<xsl:value-of select="ThisItem"/>
</Item>
</Base>
</xsl:with-param>
</xsl:template>
你为什么想做这个? 在我的 XSLT 中,我通过递归参数调用构建了一个临时树。我想输出临时树,因为它正在构建到单独的文档中,但仍然使用为控制流而构建的临时树。使用当前方法,我必须进行两次复杂的转换。
有没有办法在 XSLT 中做到这一点,还是单程单文档?
提前致谢。