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

Re: trouble checking "cousins"of current node

Subject: Re: trouble checking "cousins"of current node
From: "Chris d'Aquin" <CDAquin@xxxxxxxxxxx>
Date: Fri, 21 Sep 2001 17:03:32 -0500
xpath find previous cousin node
>If this isn't enough help (maybe I've misread your problem), maybe you
>could post your present XSLT and an example of the output you would like.

I already use the following:: axis quite extensively.  Instead of giving
you my complicated script, I will try to describe it and give samples of
its most important xpath statements.

Given this XML structure:
<root>
   <document date="2001.06.03">
      <war title="a" complete="yes"> . . . </war>
      <legislation title="b" complete="yes"> . . . </legislation>
      <war title="c" complete="no"> . . . </war>
   </document>
   <document date="2001.06.10">
      <civil-event title="d" complete="yes">  . . . </civil-event>
   </document>
   <document date="2001.06.17">
      <war title="c" complete="continued"> . . . </war>
      <exploration title="e" complete="yes"> . . . </exploration>
   </document>
<root>

In the XSL, I first use <xsl:for-each select="//*[@complete]"> to find all
tags with the complete attribute (complete="yes" is the default, so this
for-each statement skips "yes" tags).  Then I create a variable called
$element that contains the name of the tag I am on.  Therefore, if I am on
<war title="c" complete="no">, then I can use <xsl:when test="following::
*[name()=$element][1][@complete='continued']"> and <xsl:when test="
@title=following::*[name()=$element][1]/@title]"> to make sure to make sure
the next <war> completes the previous one.  I have similar checks for when
@complete=continued, but it uses the preceding:: axis.

Looking at another XML sample, if it is like this:

<root>
   <document date="2001.06.03">
      <war title="c" complete="no"> . . . </war>
   </document>
   <document date="2001.06.10">
      <civil-event title="d" complete="yes"> . . . </civil-event>
          <!-- civil-event interrupts the flow but war is continued in this
class -->
      <war title="c" complete="continued"> . . . </war>
   </document>
</root>

Then I can find the interrupting <civil-event title="d"> by the xpath
statement "following::*[name()
=$element][1]/preceding-sibling::civil-event".  But if the <civil-event
title="d"> takes up the whole class (or, in other words is the only child
of <document>) as it does in the first XML sample, then this xpath
statement doesn't work.  It seems I can find everything but this situation.
This is what I need help with.

Thanks again,
Chris

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Chris d'Aquin, XML Engineer
Questia Media, Inc.
713.358.2515
cdaquin@xxxxxxxxxxx
http://www.questia.com/
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


 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.