Hi,
to generate XSLT-Stylesheets i need a generic solution to set a context for relative XPath-expressions (or not relative). I've used:
Code:
<xsl:variable name="context" select="//context"/>
<xsl:value-of select="$context/(relativeXPath)"/>
Almost every time it works very fine. But now i have a problem, if the relativeXPath includes some for-loops. For example:
XML:
Code:
<context>
<node a="1"/>
<node a="2"/>
</context>
<difContext/>
both templates below should do the same thing, but they don't.
this (not "generic" variant) works, like it should:
Code:
<xsl:template match="context">
<xsl:copy-of select="for $i in 0 to 1 return node[@a>$i]"/>
</xsl:template>
it returns:
Code:
<node a="1"/><node a="2"/><node a="2"/>
But this "generic" variant copies just both <node>-elements:
Code:
<xsl:template match="difContext">
<xsl:variable name="context" select="//context"/>
<xsl:copy-of select="$context/(for $i in 0 to 1 return node[@a>$i])"/>
</xsl:template>
output:
Code:
<node a="1"/><node a="2"/>
i dont understand why!? is there a reason for this difference? is there a workaround?
(i use oXygen 12.0 with Saxon-PE 9.2.1.2 on Win 7)
thanks for help!