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

Re: Iteration

Subject: Re: Iteration
From: Mike Brown <mike@xxxxxxxx>
Date: Sat, 1 Jul 2000 15:44:01 -0600 (MDT)
Re: Iteration
> I'm trying to use XSL to parse XML to PROLOG, and cannot find
> a means of iterating over every element.

<xsl:template match="/">
  <xsl:apply-templates select="//*"/>
</xsl:template>

<xsl:template match="*">
  <!-- stuff to do for each element here -->
</xsl:template>

or, since //foo is inefficient,

<xsl:template match="/">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="*">
  <!-- stuff to do for each element here -->
  <!-- when done, go process this element's child elements -->
  <xsl:apply-templates select="*"/>
</xsl:template>

<xsl:template match="text()|comment()|processing-instruction|@*"/>

> Is it possible, say,
> to use XSL without additional ECMA/VB-/J-/JavaScript scripting
> to display every element and it's attributes?

Replace <!-- stuff to do... --> with the appropriate code, depending on
the output you want. Example:

<xsl:value-of select="concat(name(),': ',text(),'&#xA;')"/>
<xsl:for-each select="@*">
  <xsl:value-of select="concat('   ',name(),': ',text(),'&#xA;')"/>
</xsl:for-each>

would give you something like:

element1: text1
  attribute1a: value1a
  attribute1b: value1b
element2: text2
  attribute2a: value2a
element3: text3

etc.

   - Mike
____________________________________________________________________
Mike J. Brown, software engineer at         My XML/XSL resources:
webb.net in Denver, Colorado, USA           http://www.skew.org/xml/


 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.