[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] preceding-sibling:: oddity

Subject: [xsl] preceding-sibling:: oddity
From: Jeff Hooker <jeff@xxxxxxxxxxxx>
Date: Wed, 13 Jun 2012 14:26:42 -0700 (PDT)

Hi all,

Using XSLT 2.0 and Saxon HE

I've got an XML document
generated from Excel and am writing a script to extract it into something more

I've got a way of establishing a reference point in the document,
and am drawing data from behind it and in front of in order to convert a
simple table into a semantic format. However, I'm seeing some strange behavior
with preceding-sibling::. 

The current content node is ss:Cell[11], given
that, can anyone point out why:

  <xsl:element name="package_pin"> 
<xsl:value-of select="preceding-sibling::ss:Cell[6]"/>
fails, yet:

  <xsl:for-each select="preceding-sibling::ss:Cell">
<xsl:if test="number(count(preceding-sibling::ss:Cell)+1) = 6">
<xsl:element name="general_cell">
               <xsl:value-of select="."/>

succeeds in
drawing the content from the 6th cell in the current row?

As far as I can
see, both start from the same context and test for the same condition, but one
is direct and fails the other one reroutes flights from New York to Buffalo
through Tokyo and succeeds. I'm baffled.


Current Thread