[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: figuring out if one tag was directly preceding by anothe

Subject: Re: figuring out if one tag was directly preceding by another
From: Mike Brown <mike@xxxxxxxx>
Date: Wed, 11 Oct 2000 15:07:16 -0600 (MDT)
preceding sibling
Eric Taylor wrote:
> Simplified, part of my XML looks like this:
> 
>    <para>here is some content<button.../> more optional content <link...
> /></para>
> 
> My problem is that if there is nothing between button and link (i.e.,
> <button.../><link... />) then I need to do something marginally different
> than if there is intervening content.  Is there any way to identify when
> processing the link template whether it was directly preceded by button.
> Thanks  Eric

'something' intervening = a text node is the 'link' element's preceding
sibling. 'nothing' intervening = an element node ('button') is the link
element's preceding sibling.

so if you have a template that matches "link" elements, you could probably
do something like

<xsl:if test="generate-id(preceding-sibling::node()[1]) =
generate-id(preceding-sibling::*[1])"/>
  ...
</xsl:if>

to test for the first preceding sibling node and the first preceding
element having the same internal ID (and thus being the same node). The
predicate [1] on each is probably not necessary since generate-id() will
only look at the first node in the given set, but I've included it for
clarity.

Untested code.

   - Mike
____________________________________________________________________
Mike J. Brown, software engineer at         My XML/XSL resources:
webb.net in Denver, Colorado, USA           http://www.skew.org/xml/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.