XSL 中有什么方法可以更新全局变量吗?
我想检查我已经转换了哪些元素并采取相应的行动。这将需要我以某种方式将元素的名称添加到某种列表中,并在每次转换新元素时更新它。
但是由于xsl:variable
它不是人们期望的“变量”,所以一旦它被定义,我就无法添加任何东西。
我有多个包含的数据文件,因此使用只知道当前节点集的 xsl 函数将无济于事。
== 编辑 ==
这就是我现在的转变。但它会包含每次在不同子文件中重复引用的文件。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- include the contents of referenced files -->
<xsl:template match="reference">
<xsl:apply-templates select="document(@url)/data/node()" />
</xsl:template>
</xsl:transform>
数据文件看起来像这样:
<data>
<reference url="another_data_file.xml"/>
... other stuff ...
</data>