xsl-list
[Top] [All Lists]

RE: XPath Problem - selecting the previos node

2004-10-25 02:27:57
Hi,

I need to store the value of the first previous sibling, 
which doesn't start with "-" in a variable.

Heres my XML:

<?xml version="1.0" encoding="UTF-8"?>
<norm xmlns="http://www.lexisnexis.at/schema/norm"; id="abgb">
      <stichworte>
              <stichwort_alt>Abgerissenes Land 412(1)</stichwort_alt>
              <stichwort_alt>Abhandlung der Erbschaft 
797</stichwort_alt>
              <stichwort_alt>Anerkennung der Vaterschaft 
154</stichwort_alt>
              <stichwort_alt>-, Rechtswirksamerklärung 
164</stichwort_alt>
              <stichwort_alt>-, Widerspruch 163d, 163e</stichwort_alt>
...


I need to replace leading "-" with the first word of the 
previous sibling not beginging with "-". 
So my desired output should look like

      ...
      <stichwort_alt>Anerkennung der Vaterschaft 154</stichwort_alt>
      <stichwort_alt> Anerkennung, Rechtswirksamerklärung 
164</stichwort_alt>
      <stichwort_alt> Anerkennung, Widerspruch 163d, 
163e</stichwort_alt>

You want

  preceding-sibling::ln:stichwort_alt[not(starts-with(., '-'))][1]

i.e. the first match in reverse document order.

Cheers,

Jarno - In Strict Confidence: Another Night


<Prev in Thread] Current Thread [Next in Thread>