[xsl] Next node outside of axis pattern

Subject: [xsl] Next node outside of axis pattern
From: Spencer Tickner <spencertickner@xxxxxxxxx>
Date: Fri, 17 Jul 2009 15:24:59 -0700
Hello everyone and thanks in advance for any help. If I had an XML
like the following (snippet tried to cover off most scenarios):

<?xml version="1.0"?>
<root>
	<a>This is some text</a>
	<s>
		<section>
			<toc>Heading 1</toc>
			<p>This is<endofpage num="1"/> a paragraph</p>
			<p>This is a paragraph</p>
		</section>
		<section>
			<toc>Heading 2</toc>
			<p>This is a paragraph</p>
		</section>
		<section>
			<p>This is a paragraph</p>
			<p>This<endofpage num="2"/> is a paragraph</p>
			<li>
				<p>This is a paragraph</p>
				<p>This is a paragraph</p>
			</li>
		</section>
		<section>
			<toc>Heading 3</toc>
			<p>This is a paragraph</p>
		</section>
	</s>
	<a>This<endofpage num="3"/> is some more text</a>
	<p>This is a paragraph</p>
</root>

the <endofpage> element can appear anywhere within the document in an
element that contains text. The issues is building a table of contents
of the <toc> elements. For <toc>Heading 1</toc> no problem using
descendant axis. However with Heading 2 and Heading 3 I can't figure
out how to get the page number. I'm looking for something like:

<xsl:template match="toc">
<p><xsl:value-of select="."/> ......... <!-- next endofpage/@num goes
here --></p>
</xsl:template>


Any thoughts?

Thanks,

Spencer

Current Thread