This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Problem with preceding-sibling, my code, or my tool? Read on...
- To: "'XSL-List at lists dot mulberrytech dot com'" <XSL-List at lists dot mulberrytech dot com>
- Subject: [xsl] Problem with preceding-sibling, my code, or my tool? Read on...
- From: Martin Streicher <mstreicher at moodlogic dot com>
- Date: Fri, 1 Jun 2001 14:24:02 -0700
- Cc: Martin Streicher <mstreicher at moodlogic dot com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
I have the read the FAQs on axes, yet I still have a problem....
For the input...
<?xml version="1.0" encoding="UTF-8"?>
<list>
<char/>
<item value="1">one
<sub>subone</sub>
</item>
<item value="2">two
<sub>subtwo</sub>
</item>
<item value="3">three</item>
</list>
And the XSLT stylesheet....
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method='xml'/>
<xsl:template match="list">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="item">
<xsl:if test="name(preceding-sibling::*[1])=name(.)">
Pre:<xsl:value-of select="name(preceding-sibling::*[1])"/>
Me:<xsl:value-of select="name(.)"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Why does the test always fail? If instead I use preceding-sibling::item[1],
the test works fine. I don't get it.
Help! This is critical. I need to know if the immediate previous (and also
immediate next using
following-sibling) are the same element type as the context node.
Martin
mstreicher@moodlogic.com <mailto:mstreicher@moodlogic.com>
P.S. I am running this under XSL Designer 1.02.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list