At 2012-06-13 14:26 -0700, Jeff Hooker wrote:
Using XSLT 2.0 and Saxon HE 9.3.0.5
I've got an XML document generated from Excel and am writing a
script to extract it into something more semantic.
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]"/>
</xsl:element>
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="."/>
</xsl:element>
</xsl:if>
</xsl:for-each>
succeeds in drawing the content from the 6th cell in the current row?
Because the preceding-sibling:: axis is addressed, as all
parent/child/sibling axes, in proximity order, which means the
closest one is numbered 1 and the next closest is 2, etc. The
preceding-sibling:: axis is, therefore, in reverse document order.
Sets of nodes are delivered to XSLT in document order, so the
for-each is working in forward document order.
In your first code fragment, the current node is ss:Cell[11] so
preceding-sibling::ss:Cell[6] addresses the 5th of the cells.
In your second code fragment you are addressing the 6th of the cells.
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.
I hope this helps.
. . . . . . . . Ken
Thanks, Jeff.
--
Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
--~------------------------------------------------------------------
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>
--~--