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

Re: iterate over data on same line

Subject: Re: iterate over data on same line
From: andrew welch <andrew.j.welch@xxxxxxxxx>
Date: Wed, 30 Nov 2005 11:54:12 +0000
re iterate
> I have the following data in my xml:
>
> <parameter name="measType">
>                 <in/>
>                 <dataType>
>                     <long>
>                         <range>
>                             <min>24</min> <max>24</max>
>                             <min>26</min> <max>26</max>
>                             <min>28</min> <max>33</max>
>                             <min>44</min> <max>44</max>
>                             <min>900</min> <max>900</max>
>                         </range>
>                     </long>
>                 </dataType>
>             </parameter>
>
>
> How can I select each pair of min AND max? I need to iterate over both. Is
it possible?

Apply-templates to all the <min> elements:

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

Then in the <min> matching template, apply-templates to the first
following-sibling <max>:

<xsl:template match="min">
  <xsl:value-of select="."/>
  <xsl:apply-templates select="following-sibling::max[1]"/>
</xsl:template>

<xsl:template match="max">
  <xsl:value-of select="."/>
</xsl:template>

You'll have to replace the value-of's with whatever output you need
for the values.

cheers
andrew

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.