[xsl] XPath location problem

Subject: [xsl] XPath location problem
From: Per Åberg <aberg.per@xxxxxxxx>
Date: Tue, 29 Aug 2006 23:15:46 +0200
Hi,
First, I want to thank Michael and Peter for your help on my question about sort order last week. My problem then was solved with the node-set extension.


My new problem is a location issue. On the XML document:
       <animal>
           <species>
               <name language="English">Wolf</name>
               <name language="Spanish">Lobo</name>
               <name language="English">Warg</name>
               <name language="Latin">Canis Lupus</name>
               <name language="French">Loup</name>
           </species>
       </animal>

I want to perform this operation: If there is more than one "name language='English'" in "species", then create a temporary node set with the "name" elements following and including the second "language='English'". Thus,
<name language="English">Wolf</name>
<name language="Spanish">Lobo</name>
<name language="English">Warg</name>
<name language="Latin">Canis Lupus</name>
<name language="French">Loup</name>
should be
<name language="English">Warg</name>
<name language="Latin">Canis Lupus</name>
<name language="French">Loup</name>


The new node set should then be placed in a variable and compared to another "species" node set, but I think I can sort that part out for myself. Is it possible to extract my wanted output with XPath? There can be any number of "name language='English'", and they can be in any position, so the solution must be generic. I work with XSL 1.0 and the Xalan processor.

Thanks in advance!
Per


Current Thread