This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: simple tree problem ...
- To: xsl-list at lists dot mulberrytech dot com
- Subject: RE: [xsl] simple tree problem ...
- From: "Christopher R. Maden" <crism at maden dot org>
- Date: Thu, 25 Oct 2001 04:23:07 -0700
- References: <000b01c15cc7$64ea2b80$ce03fea9@c366>
- Reply-To: xsl-list at lists dot mulberrytech dot com
At 02:57 25-10-2001, Michael Kay wrote:
> > First there was a tree ...
> > <snip>
> > <position> 1
> > <position> 2
> > <position/> 3
> > </position>
> > <position/> 4
> > </position>
> > <position/> 5
> > </snip>
>
>One way of doing a breadth-first tree walk is:
>
><xsl:template match="position">
> <xsl:apply-templates select="child::position" mode="visit"/>
> <xsl:apply-templates select="child::position"/>
></xsl:template>
>
><xsl:template match="position" mode="visit">
> <xsl:value-of select="."/>
></xsl:template>
Except that that latter template will get the contents of the position and
all its descendants. That would give
contents-of-1-2-3-and-4
contents-of-5
contents-of-2-and-3
contents-of-4
contents-of-3
<xsl:template match="position" mode="visit">
<xsl:apply-templates select="text()"/>
</xsl:template>
might be better.
(Of course, Mike's example was only illustrative, but pedantry is the order
of the day.)
-Chris
--
Christopher R. Maden, Principal Consultant, HMM Consulting Int'l, Inc.
DTDs/schemas - conversion - ebooks - publishing - Web - B2B - training
<URL: http://www.hmmci.com/ > <URL: http://crism.maden.org/consulting/ >
PGP Fingerprint: BBA6 4085 DED0 E176 D6D4 5DFC AC52 F825 AFEC 58DA
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list