[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: preceding sibling headaches
Subject: Re: preceding sibling headaches
From: Rick Taylor <taylor@xxxxxxxx>
Date: Tue, 22 Apr 2003 13:44:03 -0600
|
Paul,
try changing the test to this:
<xsl:when test = "name(preceding-sibling::*[1])='transition'">
I think the way you have it now simply returns the first previous
occurrence of a 'transition' element rather than testing to see if the
immediately previous element is a 'transition' element.
-rick
At 03:24 PM 4/22/03 -0400, you wrote:
I can't understand how to use preceding sibling, despite the two books I
have on xslt.
Here is my original XML file:
<paragraph>A paragraph</paragraph>
<transition/>
<paragraph>A pargraph after a transition</paragraph>
I want to transform this to:
<p>A paragraph</p>
<p rend = "transition">A paragrah after transition</p>
Here is en excerpt form my unsuccessful code:
<xsl:template match = "paragraph">
<xsl:choose>
<xsl:when test = "preceding-sibling::transition[1]">
<p rend="transition">
<xsl:apply-templates/>
</p>
</xsl:when>
<xsl:otherwise>
<p>
<xsl:apply-templates/>
</p>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
This transformation turns *all* paragraphs after a </transtion> into <p
rend ="transtion">.
What I want to say is something like "if the preceeding sibling's
element name is 'transtion', do something. Doing this with ancestors and
descendants is usually pretty easy to figure out. But preceeding sibling
really has me stumped!
Thanks
Paul
--
************************
*Paul Tremblay *
*phthenry@xxxxxxxxxxxxx*
************************
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Rick Taylor
XML Developer
PPDM Association
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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 |
|
|