[xsl] following-sibling::

Subject: [xsl] following-sibling::
From: Myles Pflum <myles_pflum@xxxxxxxxxxxxx>
Date: Fri, 6 Feb 2009 16:59:46 -0800
First time poster in need of assistance =)

Using XSLT 1.0, given the following structure:

<document>
	<aaa />
	<aaa />
	<aaa />
	<aaa />
	<aaa stylename='start' />
	<aaa />
	<aaa />
	<aaa />
	<aaa />
	<aaa stylename='finish' />
	<aaa />
	<aaa />
	<aaa />
	<aaa />
	<aaa />
	<aaa stylename='start' />
	<aaa />
	<aaa />
	<aaa stylename='finish' />
	<aaa />
	<aaa />
</document>

How can I make the <aaa /> elements that exist in between @='start' and @='finish become children of <aaa stylename='start' />?

I've tried some sibling recursion techniques and such but I can't get my XPath right. I can select all the following-siblings of @='start' until the end of the document, but I need to select all of the following-siblings of @='start' until I reach @='finish'.

I've been using <xsl:copy-of select="following- sibling::*[@stylename='finish']" /> but this selection isn't stopping when I reach the first 'finish'. It's just selecting all the 'finish' in the document.


Desired output:


<document>
	<aaa />
	<aaa />
	<aaa />
	<aaa />
	<aaa stylename='start'>
		<aaa />
		<aaa />
		<aaa />
		<aaa />
	</aaa>
	<aaa />
	<aaa />
	<aaa />
	<aaa />
	<aaa />
	<aaa stylename='start' />
		<aaa />
		<aaa />
	</aaa>
	<aaa />
	<aaa />
</document>

In addition to this selection issue, "copy-of" is simply copying the elements to the result tree without applying templates. How can I 'copy' these elements and then apply-templates?


Thanks, Myles Pflum

Current Thread