RE: Sort nodes

Discussion in 'XML' started by Guest, Dec 6, 2005.

  1. Guest

    Guest Guest

    Hi,
    Here's the XML taht I am trying to transform. Here's a concret
    example:

    <root>
    <car>
    <name>Ford</name>
    <myRating>1</myRating>
    <yourRating>3</yourRating>
    </car>

    <car>
    <name>Mazda</name>
    <myRating>2</myRating>
    <yourRating>5</yourRating>
    </car>

    <car>
    <name>Nissan</name>
    <myRating>3</myRating>
    <yourRating>2</yourRating>
    </car>
    </root>

    Business requirement: If myRating is available, use that. Us
    yourRating iff myRating is not available.
    When I try to implement this logic in my XSLT (usin
    <choose><when><otherwise>) to get 3 variables (let's say rating1
    rating2, rating3, I get a node fragment of (let's say: rating).
    I am trying to sort on this rating.

    Hope that helps,
    Harsh

    -----------------------------------------------------------------------
    IT Interview Questions : http://www.geekinterview.com IT Tutorials and Articles : http://www.geekarticles.com Oracle and Oracle Apps Training : http://www.exforsys.com
     
    Guest, Dec 6, 2005
    #1
    1. Advertising

  2. Guest

    Peter Flynn Guest

    <> wrote:

    >
    > Hi,
    > Here's the XML taht I am trying to transform. Here's a concrete
    > example:
    >
    > <root>
    > <car>
    > <name>Ford</name>
    > <myRating>1</myRating>
    > <yourRating>3</yourRating>
    > </car>
    >
    > <car>
    > <name>Mazda</name>
    > <myRating>2</myRating>
    > <yourRating>5</yourRating>
    > </car>
    >
    > <car>
    > <name>Nissan</name>
    > <myRating>3</myRating>
    > <yourRating>2</yourRating>
    > </car>
    > </root>
    >
    > Business requirement: If myRating is available, use that. Use
    > yourRating iff myRating is not available.
    > When I try to implement this logic in my XSLT (using
    > <choose><when><otherwise>) to get 3 variables (let's say rating1,
    > rating2, rating3, I get a node fragment of (let's say: rating).
    > I am trying to sort on this rating.


    I think you have to do two transforms to do this: one to generate
    a single value to use as the sort key, and the second to do the
    sorting. But maybe someone else can come up with a one-pass method.

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/
     
    Peter Flynn, Dec 9, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. asd
    Replies:
    3
    Views:
    458
    Arnaud Berger
    May 23, 2005
  2. gavnosis
    Replies:
    0
    Views:
    544
    gavnosis
    Aug 2, 2003
  3. Timo Nentwig

    selecting nodes between other nodes

    Timo Nentwig, Jun 16, 2004, in forum: XML
    Replies:
    1
    Views:
    434
    Patrick TJ McPhee
    Jun 17, 2004
  4. Johnny Ooi

    Looking A Nodes From Within Nodes

    Johnny Ooi, Nov 13, 2004, in forum: XML
    Replies:
    10
    Views:
    672
    Johnny Ooi
    Nov 14, 2004
  5. Navin
    Replies:
    1
    Views:
    761
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page