|
Subject: Re: [xsl] Finding topmost element of a nested, nested list From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 29 Oct 2003 15:50:00 GMT |
level.xml:
<chapter>1.
<level>I.
<level>A.
<section>1</section>
<section>2</section>
</level>
<level>B.
<section>3
<image/>
</section>
</level>
</level>
<level>II.
<level>A.
<section>4</section>
</level>
<level>B.
<section>5
<image/>
</section>
</level>
</level>
<level>III.
<level>A.
<section>6
<image/>
</section>
</level>
</level>
</chapter>
level.xsl:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="*" mode="x">
<xsl:apply-templates select="*[1]" mode="x"/>
</xsl:template>
<xsl:template match="image" mode="x">.</xsl:template>
<xsl:template match="level">
<xsl:variable name="x">
<xsl:apply-templates mode="x" select="."/>
</xsl:variable>
<xsl:variable name="y">
<xsl:apply-templates mode="x" select=".."/>
</xsl:variable>
<xsl:if test="string($x) and not(string($y))">
<xsl:comment>end page here</xsl:comment>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
$ saxon level.xml level.xsl
<?xml version="1.0" encoding="utf-8"?><chapter>1.
<level>I.
<level>A.
<section>1</section>
<section>2</section>
</level>
<!--end page here-->
<level>B.
<section>3
<image/>
</section>
</level>
</level>
<level>II.
<level>A.
<section>4</section>
</level>
<!--end page here-->
<level>B.
<section>5
<image/>
</section>
</level>
</level>
<!--end page here-->
<level>III.
<level>A.
<section>6
<image/>
</section>
</level>
</level>
</chapter>
--
http://www.dcarlisle.demon.co.uk/matthew
________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Finding topmost element of a , Liguori, Steven | Thread | Re: [xsl] Finding topmost element o, Wendell Piez |
| [xsl] Re: Making XPath expressions , Dimitre Novatchev | Date | RE: [xsl] non-breaking whitespace, Saverio Perugini |
| Month |