[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-dev
Subject:    RE: sorting xml data in alphabetical order
From:       "Radu Preotiuc-Pietro" <radu.preotiuc-pietro () oracle ! com>
Date:       2009-01-06 3:15:03
Message-ID: 20090105221503312.00000001196 () RADUP02
[Download RAW message or body]

You could post the XQuery you used and we could try to take a look at it and see what's wrong. Or, in the time that it will take you to debug it, you can learn to use XmlCursor and implement the functionality that way.

Radu 

> -----Original Message-----
> From: Rauf khan [mailto:forum.khan@gmail.com] 
> Sent: Tuesday, December 16, 2008 12:37 AM
> To: dev@xmlbeans.apache.org
> Subject: Re: sorting xml data in alphabetical order
> 
> 
> I was trying with the examples given at
> http://www.yukonxml.com/articles/xquery/ by using saxon8.jar. 
> Iam able to sort only ONE time means i can sort by COUNTRY & 
> not by STATE & vise versa also a part of the xml code will be 
> missed in the output.
> 
> Input XML File: countryinfo.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <World>
>     <Country name="Pakistan">
>         <State name="Karachi" population="999"/>
>         <State name="Islamabad" population="900"/>
>         <State name="Rawalpandi" population="909"/>
>     </Country>
>     <Country name="India">
>         <State name="Bangalore" population="100"/>
>         <State name="AP" population="200"/>
>         <State name="Madras" population="300"/>
>         <State name="Delhi" population="600"/>
>     </Country>
> </World>
> 
> Query to sort by Country:
> Query: for $country in doc("countryinfo.xml")/World/Country
>           order by $country/@name ascending
>           return $country
> 
> OutPut:
> <?xml version="1.0" encoding="UTF-8"?>
> <Country name="India">
>         <State name="Bangalore" population="100"/>
>         <State name="AP" population="200"/>
>         <State name="Madras" population="300"/>
>         <State name="Delhi" population="600"/>
>     </Country>
> <Country name="Pakistan">
>         <State name="Karachi" population="999"/>
>         <State name="Islamabad" population="900"/>
>         <State name="Rawalpandi" population="909"/>
>     </Country>
> 
> Query to sort by State:
> Query: for $country in doc("countryinfo.xml")/World/Country/State
>           order by $country/@name ascending
>           return $country
> 
> OutPut:
> <?xml version="1.0" encoding="UTF-8"?>
> <State name="AP" population="200"/>
> <State name="Bangalore" population="100"/> <State 
> name="Delhi" population="600"/> <State name="Islamabad" 
> population="900"/> <State name="Karachi" population="999"/> 
> <State name="Madras" population="300"/> <State 
> name="Rawalpandi" population="909"/>
> 
> Java Program:
> import net.sf.saxon.Query;
> public class SortXMLData {
>    public static void main(String[] args) {
>        Query query = new Query();
>        String arg[] = {"C:/countryinfo.xq"};  // contains query
>        try{
> 	query.main(arg);
>        } catch(Exception ex){
> 	System.out.println("Exception: "+ex);
>       }
>    }
> }
> 
> - Khan
> --
> View this message in context: 
> http://www.nabble.com/sorting-xml-data-in-alphabetical-order-t
> p19920246p21027601.html
> Sent from the Xml Beans - Dev mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: dev-help@xmlbeans.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic