Is there any way in XSL to update a global variable?
I want to check what elements i already transformed and act accordingly. That would require me to somehow add the names of the elements to some sort of list and update it each time a new element is transformed.
But since xsl:variable
isn't "variable" in the sense one would expect, i have no way of adding anything to it once it has been defined.
I have multiple included data files, so using xsl functions that only know the current set of nodes will not help.
== Edit ==
This is what my transformation looks like now. But it will include files that are repeatedly referenced in different sub-files every time.
<?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>
And the data files would look something like this:
<data>
<reference url="another_data_file.xml"/>
... other stuff ...
</data>