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

immediate preceding node within nested tags

Subject: immediate preceding node within nested tags
From: andy@xxxxxxxx
Date: Wed, 12 Nov 2003 11:12:13 -0500 (EST)
preceding node
Hi,

I have a hierarchical structure where every q-tag maps to a row in an
html-table. Only when a node is on the same level (indentation) as the
previous node, I don't want to start a new row. It just needs to be in the
same row but on a new line using <br>

So I have an XML similar to the one below (never checked well-formedness);
key-attributes are NOT part of the real XML I use. I just added them in
this example so I can reference them in the explanation that follows the
XML:

<a>
<q key="a">
  <y/>
  <q key="b">
  <b>
    <q key="c">
      <x/>
      <q key="d"/>
        <q key="e">
          <f>
        </q>
      <q key="f"/>
      <q key="g"/>
    </q>
    <q key="h">
      <j/>
      <q key="i"/>
      <q key="j"/>
    </q>
  </q>
</q>
</a>

In the XSLT that I use, I open an html-table when the root tag matches.
After that, I open a <tr> for every q-tag that matches. However, since the
q's with key="f" and key="g" are on the same level (if you look at them
from top to bottom) I want them to be in the same row separated by a <br>.
The same goes for key="i" and key="j".Therefore I must be able to find the
immediate preceding q-node, which is not necessarily a sibling. I mean
that the XSLT-function I'd like to write should return <q key="i"> when I
call it with <q key="j">, and it should return <q key="h"> if I call it
with <q key="i">. Similarly: h should return g, g should return f, etc.
etc. Hoping to make things even more clear: I don't want "d" if I call the
function with "f", but I want the <q key="e">.

I tried to use preceding and preceding-sibling, and stuff like that, but
to no avail...

It'd be great if somebody could point me in the right direction...

Thanx,
Andy.



 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.