xsl-list
[Top] [All Lists]

immediate preceding node within nested tags

2003-11-12 09:12:13
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



<Prev in Thread] Current Thread [Next in Thread>
  • immediate preceding node within nested tags, andy <=