Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   RE: Sort nodes (http://www.velocityreviews.com/forums/t170297-re-sort-nodes.html)

12-06-2005 12:40 AM

RE: Sort nodes
 

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

Peter Flynn 12-09-2005 11:19 PM

RE: Sort nodes
 
<> 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/



All times are GMT. The time now is 07:35 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.