Re: [xsl] following-sibling help please.

Subject: Re: [xsl] following-sibling help please.
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Tue, 10 Oct 2006 21:59:05 +0530
You haven't told what is your desired output. But perhaps something
like following should work for you:

<xsl:template match="totaluse[following-sibling::*[1]/self::header]">
  <totaluse>
     <!-- add something -->
  </totaluse>
</xsl:template>

(this is not tested)

On 10/10/06, Danny Leblanc <leblancd@xxxxxxxxxxxxxxxxxxx> wrote:
Hello everyone,

I have a data file that is similar in structure to the one below. What I am trying to do (and failing badly) is to add a child to <totaluse> only when the node that following it is a <header>. When another <use> following it I would not like to change anything. Basically, in the software I am using this with I need to know when I am on the last <totaluse> element for the current "set" (a set starts with the <header>). I cannot add (due to software limitations) a parent around each set. Everything must be on the second level of the XML file as it is below.

I have been toying around with following-sibling:: but have not managed to figure out how to format it. I have found that following-sibling will return all the following siblings but I just need to test the very next one for its name. If the name is use I know not to add anything and if the name is header I know to add something.

I am using Saxon 8.7.3

Hopefully this makes some sense.



<root>
 <header>
   <info></info>
 </header>
 <use>
   <useinfo></useinfo>
 </use>
 <use>
   <useinfo></useinfo>
 </use>
 <use>
   <useinfo></useinfo>
 </use>
 <totaluse></totaluse>
 <use>
   <useinfo></useinfo>
 </use>
 <use>
   <useinfo></useinfo>
 </use>
 <totaluse></totaluse>
 <header>
   <info></info>
 </header>
</root>

Thank you.

Danny


--
Regards,
Mukul Gandhi

Current Thread