[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Sorting and replacing content


Subject: RE: [xsl] Sorting and replacing content
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Wed, 1 Sep 2004 14:51:07 +0300

Hi,

> What I have learned from this forum is to be very precise
> when making an
> example to try to simplify a real life situation.
>
> In the real case the tags <A> to <E> are more like <Order1>
> to <Order5> and
> <a> to <e> are like <Show1> to <Show5>. That will make the
> use of uppercase
> / lowercase functions useless.
>
> <Root>
>     </...>
>     <Show1>10</Show1>
>     <Show2>20</Show2>
>     <Show3>30</Show3>
>     <Show4>40</Show4>
>     <Show5>50</Show5>
>     </...>
>     ...
>     ...
>     <Order1>3</Order1>
>     <Order2>5</Order2>
>     <Order3>1</Order3>
>     <Order4>2</Order4>
>     <Order5>4</Order5>
>     </..>
> </Root>
>
> And it needs to be:
>
> <no>30</no>
> <no>40</no>
> <no>10</no>
> <no>50</no>
> <no>20</no>

In that case,

  <xsl:template match="Root">
    <xsl:for-each select="*[starts-with(name(), 'Order')]">
      <xsl:sort select="." data-type="number"/>
      <no>
        <xsl:value-of select="../*[name() = concat('Show',
substring(name(current()), 6))]"/>
      </no>
    </xsl:for-each>
  </xsl:template>

Oh-I-do-hate-flat-hunting-stressed-cheers,

Jarno - Madam Zu: March 2004


Current Thread