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

AW: Finding immediately preceding node.

Subject: AW: Finding immediately preceding node.
From: Markus Abt <abt@xxxxxxxx>
Date: Mon, 2 Jun 2003 19:17:34 +0200
preceding nodes in xsl
Hi Betty,

your test is wrong. "Inside" b, i.e. in a template for c, try:
<xsl:if test="parent::b[@name='cde']/preceding-sibling::b[1]/@name='abc'">

The expression //c/../b[@name='cde']/preceding-sibling::b[1]/@name='abc'
is true, because your XML is maybe not what you wanted: The first
c element is not inside the first b element, which is empty.
Thus, //c/.. takes you to the a element and all but the first b elements.
>From the a element, the part /b[@name=...] takes you to the 4th b...

Regards,
Markus

__________________________
Markus Abt
Comet Computer GmbH
Rueckertstrasse 5
80336 Muenchen
GERMANY
Phone +49 89 5445 6045
Fax +49 89 5445 6046
http://www.comet.de
mailto:abt@xxxxxxxx



----------
Von: 	Betty Harvey
Gesendet: 	Montag, 2. Juni 2003 15:56
An: 	xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Betreff: 	 Finding immediately preceding node.


I have been struggling with this problem and I can't seem to
get the XPath to work.  I have looked through the archive and
can't seem to find the answer.

I want to get the a true when I am inside <b name="cde"> and
the preceding <b> contains the attribute 'name="abc"'.  

<?xml version="1.0"?>
<a>
  <b name="abc"/>
     <c/>
  <b>
     <c/>
  </b>
  <b name="abc">
     <c/>
  </b>
  <b name="cde">
    <c/>
  </b>
  <b>
     <c/>
  </b>
  <b>
     <c/>
  </b>
  <b name="abc">
     <c/>
  </b>
</a>

The following XPath gives a value of true in 'XPathTester':

//c/../b[@name='cde']/preceding-sibling::b[1]/@name='abc'

I have the following in my xslt but never get a 'true':

<xsl:if test="../b[@name='cde']/preceding-sibling::b[1]/@name='abc'">

Thanks!

Betty

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Betty Harvey                         | Phone: 410-787-9200 FAX: 9830 
Electronic Commerce Connection, Inc. |        
harvey@xxxxxxxxxx                    | Washington,DC XML Users Grp
URL:  http://www.eccnet.com          | http://www.eccnet.com/xmlug
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/  


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



 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.