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

RE: iterating over unstructured data

Subject: RE: iterating over unstructured data
From: "Andrew Welch" <andrew@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 4 Feb 2002 13:11:57 -0000
RE:  iterating over unstructured data
Thanks Mike, I was looking for the non for-each solution.  Performance
wise - which is best?

cheers

andrew

===

[ps.  <xsl:template match="bar"/> needed to include <xsl:value-of
select="."/> to output the text for anyone else using this]

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Michael Kay
Sent: Monday, February 04, 2002 12:30 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  iterating over unstructured data


>
> This may be a faq, but my searches have so far been unproductive.
>
> For the data:
>
> <root>
>   <foo>1</foo>
>   <bar>2</bar>
>   <foo>3</foo>
>   <bar>4</bar>
>   <foo>5</foo>
>   <bar>6</bar>
>   <foo>7</foo>
>   <bar>8</bar>
>   <foo>9</foo>
>   <bar>10</bar>
> </root>
>
> I want to output the following format (foo followed by bar on
> each line):
>
> 1	2
> 3	4
> 5	6
> 7	8
> 9	10
>
> What is the best way of going about this?
>
<xsl:template match="foo">
<tr>
<td><xsl:value-of select="."/></td>
<td><xsl:value-of select="following-sibling::bar[1]"/></td>
</tr>
</xsl:template>

<xsl:template match="bar"/>

<xsl:template match="root">
<table>
<xsl:apply-templates select="foo"/>
</table>
</xsl:template>

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 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.