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

RE: Sorting and replacing content

Subject: RE: Sorting and replacing content
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Wed, 1 Sep 2004 12:41:25 +0300
RE:  Sorting and replacing content
Hi,

> I can manage to make a stylesheet with an <xsl:if> for each <A> to <E>
> asking whether the number is 1, 2, 3, 4 or 5, but I am sure
> there must be a
> simpler way to do this. I can not use position() since the
> position af the
> tags can change in the structure.
>
> <Root>
> <a>10</a>
> <b>20</b>
> <c>30</c>
> <d>40</d>
> <e>50</e>
> ...
>
> ...
> <A>3</A>
> <B>5</B>
> <C>1</C>
> <D>2</D>
> <E>4</E>
> </Root>
>
> Result I need:
>
> <no>30</no> <!-- C = 1 has to be first with the value of c
> (which is 30) -->
> <no>40</no>
> <no>10</no>
> <no>50</no>
> <no>30</no>

For example

  <xsl:template match="Root">
    <xsl:for-each select="A | A/following-sibling::*">
      <xsl:sort select="." data-type="number"/>
      <no>
        <xsl:value-of select="../*[name() = translate(name(current()),
'ABCDE', 'abcde')]"/>
      </no>
    </xsl:for-each>
  </xsl:template>

Cheers,

Jarno

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.