RE: [xsl] XPath Problem - selecting the previos node

Subject: RE: [xsl] XPath Problem - selecting the previos node
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Mon, 25 Oct 2004 12:27:57 +0300
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>-, Rechtswirksamerkldrung
> 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, Rechtswirksamerkldrung
> 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

Current Thread