xsl-list
[Top] [All Lists]

Re: iterate over data on same line

2005-11-30 04:54:12
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>