[Home] [By Thread] [By Date] [Recent Entries]
At 2009-07-17 15:24 -0700, Spencer Tickner wrote:
If I had an XML like the following (snippet tried to cover off most scenarios): So by "next" do you need the "closest" <endofpage> element to the start of each given section with a <toc>? Since you are already in a section's child, that would entail going up to the parent of <toc> and down as well as those that follow, so the first of the union of those addressed elements: (..//endofpage | ../following::endofpage)[1] ... though I would strongly suggest you revisit your XML to see if the <endofpage> can be more logically positioned. I understand of course that many times we have to deal with what we are given, but it would seem to me there are too many opportunities for a misplaced <endofpage> element. I hope the example below helps. . . . . . . . . . . Ken T:\ftemp>type tickner.xml
<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>
<xsl:output indent="yes"/> <xsl:template match="/">
<table-of-contents>
<xsl:apply-templates select="//toc"/>
</table-of-contents>
</xsl:template><xsl:template match="toc">
<p>
<xsl:value-of select="."/>
<xsl:text>...............</xsl:text>
<xsl:value-of select="(..//endofpage | ../following::endofpage)[1]/@num"/>
</p>
</xsl:template></xsl:stylesheet> T:\ftemp>
|

Cart



