I have two XSLT file A.xslt and B.xslt, where A.xslt includes B.xslt.
A.xslt
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="my_namespace">
<my:data>This is A.xslt</my:data>
<xsl:include href="B.xslt"/>
<xsl:template name="my_template">
<xsl:value-of select="$remote-data"/>
</xsl:template>
</xsl:stylesheet>
B.xslt
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="my_namespace">
<xsl:variable name="remote-data"
select="document('')/*/my:data" />
</xsl:stylesheet>
Of course when my_template is evaluated, empty line is outputted. This happens because B.xslt does not cantain my:data container and document('')
call is processed before include.
My question is: how can I access my:data from B.xslt (Make document('')
to be processed after inclusion)?
Any ideas are appreciated!
Update: In real life I have multiple files like A.xslt: A1.xslt, A2.xslt,... and it is needed to make exactly the same calculations with nodeset as a result (like in $remote-data
definition) but with different parameters (stored in my:data).
One can say that I can use named template for that. But as far as I can see it is not possible to do this, because template would return RTF, which I have to node-set()
which is generally not available in XSLT 1.0 parsers.
Hope this clarifies my problem.