2 Replies Latest reply on Apr 23, 2012 2:34 PM by Nakur

    Basic doubt and problem with my query

      Hi friends

      I am pretty new to this xquery .I had to learn and implement it in my project.We have many rules to follow so basically i have an XML already provided.I need to work on several issues.When i am working i have come across different errors or very small minor problems.here is question1

      1)i am trying to find the LArgest population in whole..Here is the quesry i am using

      declare variable $xmldoc1:= doc("mondial-3.0.xml");
      let $test := max($xmldoc1/mondial/country/@population)
      for $a in $xmldoc1/mondial/country where  $a/encompassed/@continent ="f0_132" and $a/@population=$test

      I am not able to display any thing but when i take out the condition $a/@population=$test out i am able to see all the name..

      Help me friends ..THank you
        • 1. Re: Basic doubt and problem with my query
          The query doesn't return anything because, most likely, the country with max population doesn't belong to the continent whose id = "f0_132", simple as that.

          Remove the following condition and see the difference :
          $a/encompassed/@continent ="f0_132"
          • 2. Re: Basic doubt and problem with my query
            I think you'll be just fine changing the order of your two statements. As odie_63 already pointed out, the max population country is probably in another continent.
            You might want to try something like this:

            declare variable $xmldoc1:= doc("mondial-3.0.xml");
            for $a in $xmldoc1/mondial/country[encompassed/@continent ='f0_132']
            let $maxpop := max($a/@population)
            where $a/@population = $maxpop

            Good luck!