[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: simple tree problem ...

Subject: RE: simple tree problem ...
From: "Christopher R. Maden" <crism@xxxxxxxxx>
Date: Thu, 25 Oct 2001 04:23:07 -0700
position mod 3 xml publisher
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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.