|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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(),'
')"/>
<xsl:for-each select="@*">
<xsl:value-of select="concat(' ',name(),': ',text(),'
')"/>
</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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








