Subject: Re: limitations of xslt
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Sun, 24 Oct 1999 19:23:31 +0100
|
You will find that the following gives you what you want - not
commented, but I've tried to keep it simple by flattening the structure.
Not sure how scaleable this approach compared to others - any comments,
anyone?
Francis.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<result>
<xsl:apply-templates select="//title" />
</result>
</xsl:template>
<xsl:template match="title">
<section>
<sectionTitle>
<xsl:value-of select="text()" />
</sectionTitle>
<xsl:apply-templates
select="following-sibling::*[1][not(self::title)]" />
</section>
</xsl:template>
<xsl:template
match="bullet[preceding-sibling::*[1][not(self::bullet)]]">
<ul>
<li>
<xsl:value-of select="text()" />
</li>
<xsl:apply-templates select="following-sibling::*[1][self::bullet]"
/>
</ul>
<xsl:apply-templates
select="following-sibling::*[not(self::bullet)][1][not(self::title)]" />
</xsl:template>
<xsl:template match="bullet">
<li>
<xsl:value-of select="text()" />
</li>
<xsl:apply-templates select="following-sibling::*[1][self::bullet]" />
</xsl:template>
<xsl:template match="normal">
<text>
<xsl:value-of select="text()" />
</text>
<xsl:apply-templates
select="following-sibling::*[1][not(self::title)]" />
</xsl:template>
</xsl:stylesheet>
Earl Bingham wrote:
>
> Here is my input file:
>
> <?xml version="1.0"?>
> <textItems>
> <title>Here is my first title!</title>
> <bullet>first group first bullet</bullet>
> <bullet>first group second bullet</bullet>
> <normal>first group first normal</normal>
> <bullet>first group third bullet</bullet>
> <title>Here is my second title!</title>
> <bullet>second group first bullet</bullet>
> <normal>second group first normal</normal>
> <bullet>second group second bullet</bullet>
> <bullet>second group third bullet</bullet>
> </textItems>
>
....
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|