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
--~------------------------------------------------------------------
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>
--~--