[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: preceding-sibling:: oddity
Subject: Re: preceding-sibling:: oddity
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 13 Jun 2012 22:42:33 +0100
|
On 13/06/2012 22:26, Jeff Hooker wrote:
Hi all,
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:
That selects the 6th Cell counting backwards (so the 5th child)
<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?
That, as you say, selects the 6th child by a trtuous route.
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.
in a step using a reverse axis [] counts in reverse order, but the
result of the entire expression is the sequence in document order, so
preceding-sibling::ss:Cell[1]
is the immediately preceding Cell, but
(preceding-sibling::ss:Cell)[1]
is the first Cell in the sequence of preceding Cells (ie the first Cell
child of the parent if it selects anything)
David
Thanks,
Jeff.
--
google plus: https:/profiles.google.com/d.p.carlisle
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|