This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

.. and parent::node()


This is a situation where SAXON (version 5.4) handles '..' and
'parent::node()' in different ways. 'parent::node()' returns an empty
node-set when applied to the document element, while '..' doesn't. XT
behaves the same.

Stylesheet:
  <xsl:template match="*|/">
    <crt-node type="{name()}">
      <xsl:choose>
        <xsl:when test="parent::node()">NOT ROOT</xsl:when>
        <xsl:otherwise>ROOT</xsl:otherwise>
      </xsl:choose>
    </crt-node>
    <xsl:apply-templates/>
  </xsl:template>

Input file:
<list>
  <group>
   <element id="1"/>
   <element id="2"/>
   <element id="3"/>
  </group>
</list>

Output:
<crt-node type="">ROOT</crt-node>
<crt-node type="list">ROOT</crt-node>
<crt-node type="group">NOT ROOT</crt-node>
<crt-node type="element">NOT ROOT</crt-node>
<crt-node type="element">NOT ROOT</crt-node>
<crt-node type="element">NOT ROOT</crt-node>

If the test in xsl:when is replaced by ".." SAXON works as expected:
<crt-node type="">ROOT</crt-node>
<crt-node type="list">NOT ROOT</crt-node>
<crt-node type="group">NOT ROOT</crt-node>
<crt-node type="element">NOT ROOT</crt-node>
<crt-node type="element">NOT ROOT</crt-node>
<crt-node type="element">NOT ROOT</crt-node>

SAXON bug?



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]