F
Filip Hendrickx
Hi all.
I am processing two documents with an XSLT, one is the input document,
the other is loaded with the document() function in a variable $doc2.
Inside a template that matches an element from $doc2, I need to check a
value from the original input document. However, inside this template,
the context is $doc2. What XPath expression should I use to refer to the
input document? I've tried using /inputNamespace:inputElement, where
inputNamespace and inputElement refer to the input document. This
doesn't work because no such element exists within the context of the
template, which is $doc2.
A small example may clarify want I mean .
<xsl:stylesheet>
<xsl:template match="/">
<xsl:variable name="doc2" select="document('doc2.xml')"/>
<xsl:apply-templates select="$doc2/someNodeInDoc2"/>
</xsl:template>
<xsl:template match="someNodeInDoc2">
<xsl:variable name="someNodeInInputDoc" select="XPath expression
referring input document"/>
...
</xsl:template>
</xsl:stylesheet>
I solved the problem by defining an additional variable $inputDoc for
the input document and then using $inputDoc/someNodeInInputDoc, but
isn't there a way to directly access the input document, without
explicitly having to load the input document?
Thanks!
Filip Hendrickx.
I am processing two documents with an XSLT, one is the input document,
the other is loaded with the document() function in a variable $doc2.
Inside a template that matches an element from $doc2, I need to check a
value from the original input document. However, inside this template,
the context is $doc2. What XPath expression should I use to refer to the
input document? I've tried using /inputNamespace:inputElement, where
inputNamespace and inputElement refer to the input document. This
doesn't work because no such element exists within the context of the
template, which is $doc2.
A small example may clarify want I mean .
<xsl:stylesheet>
<xsl:template match="/">
<xsl:variable name="doc2" select="document('doc2.xml')"/>
<xsl:apply-templates select="$doc2/someNodeInDoc2"/>
</xsl:template>
<xsl:template match="someNodeInDoc2">
<xsl:variable name="someNodeInInputDoc" select="XPath expression
referring input document"/>
...
</xsl:template>
</xsl:stylesheet>
I solved the problem by defining an additional variable $inputDoc for
the input document and then using $inputDoc/someNodeInInputDoc, but
isn't there a way to directly access the input document, without
explicitly having to load the input document?
Thanks!
Filip Hendrickx.