Hello,
I am trying to find an explanation for the following behavior:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" xmlns:ns1="urn:ns1"
xmlns:ns2="urn:ns2">
<xsl:param name="param1"/>
<xsl:param name="param2"/>
<xsl:template match="/">
<ns3:Element1 xmlns:ns3="urn:ns3">
<xsl:for-each select="$param1/ns1:Element1">
<ns3:Element2>
<xsl:value-of
select="$param2/ns2:Element1/ns2:Element2 = ns1:Element2"/> <!--
returns "true" -->
</ns3:Element2>
<ns3:Element3>
<xsl:value-of
select="$param2/ns2:Element1[ns2:Element2 =
ns1:Element2]/ns2:Element3"/> <!-- returns empty -->
</ns3:Element3>
</xsl:for-each>
</ns3:Element1>
</xsl:template>
</xsl:stylesheet>
Using Saxon 8.4, the expression doesn't evaluate as expected when
used as a predicate, unless it is assigned to a variable first:
<?xml version=" 1.0 " encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="urn:ns1"
xmlns:ns2="urn:ns2">
<xsl:param name="param1"/>
<xsl:param name="param2"/>
<xsl:template match="/">
<ns3:Element1 xmlns:ns3="urn:ns3">
<xsl:for-each select="$param1/ns1:Element1">
<xsl:variable name="variable1" select="ns1:Element2"/>
<ns3:Element2>
<xsl:value-of
select="$param2/ns2:Element1/ns2:Element2 = $variable1"/> <!-- returns
"true" -->
</ns3:Element2>
<ns3:Element3>
<xsl:value-of
select="$param2/ns2:Element1[ns2:Element2 =
$variable1]/ns2:Element3"/> <!-- returns "value1" -->
</ns3:Element3>
</xsl:for-each>
</ns3:Element1>
</xsl:template>
</xsl:stylesheet>
These are the inputs:
<ns1:Element1 xmlns:ns1="urn:ns1">
<ns1:Element2>Test</ns1:Element2>
</ns1:Element1>
<ns2:Element1 xmlns:ns2="urn:ns2">
<ns2:Element2 attribute1="value1">Test</ns2:Element2>
<ns2:Element3>value1</ns3:Element3>
</ns2:Element1>
Can someone tell me why is it so?
Thanks,
Fernando
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--