[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Why XQUERY is needed when XPATH is already there ?

Posted on 2007-11-22
6
Medium Priority
?
403 Views
Last Modified: 2013-11-18
Hi,

Can you please explain me in simple terms why XQUERY is necessary when XPATH is already there ?

Thanks
0
Comment
Question by:kishore_peddi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 20336455
XPath is an addressing mechanism, that is used to address portions of an XML document
XQuery is a query language that uses XPath for addressing

XPath only serves the addressing part of the equation
If you want to create something out of a source XML, you need some sort of a programming language around XPath
(an example would be the DOM expression in JavaScript, as you did in your previous question)
There are two standardised languages that use XPath for addressing, but also allow to do something with the result
XQuery if the bulk of the work is searching and creating some sort of resultset
XSLT if the bulk of the work is transformation

XPath returns a nodeset. JavaScript DOM, XQuery or XSLT do something with this nodeset

I hope this clarifies things

If you want to do something with a browser, you need JavaScript DOM or XSLT
XQuery requires XPath2 and there is no support for that in browsers yet

cheers

Geert
0
 

Author Comment

by:kishore_peddi
ID: 20336485
I have the following info:

"XQuery is to XML what SQL is to database tables" - especially like FOR, LET, WHERE, ORDER BY, RETURN.

By using this XML can you provide FLWOR example ?

<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
      <book category="COOKING">
            <title lang="en">Everyday Italian</title>
            <author>Giada De Laurentiis</author>
              <year>2005</year>
              <price>30.00</price>
      </book>
      <book category="CHILDREN">
              <title lang="en">Harry Potter</title>
              <author>J K. Rowling</author>
              <year>2005</year>
              <price>29.99</price>
      </book>
      <book category="WINDOWS">
              <title lang="en">Learning VB.NET and VC#.NET</title>
              <author>James Linn</author>
              <year>2003</year>
              <price>49.99</price>
      </book>
      <book category="WEB">
              <title lang="en">Learning HTML</title>
              <author>Erik T. Ray</author>
              <year>2003</year>
              <price>39.95</price>
      </book>
</bookstore>

Appreciate your time, effort and patience !!

Thanks

0
 

Author Comment

by:kishore_peddi
ID: 20337012
Here is the HTML file i have tried - for simple example. But it does not work for me IE:

<html>
      <body>
     
      <script type="text/vbscript">
     
      for $x in doc("Books.xml")/bookstore/book
      where $x/price>30
      order by $x/title
      return $x/title

      </script>
     
      </body>
</html>

Can you please let me know where i am missing ? Thanks
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:kishore_peddi
ID: 20337051
<html>
      <body>
     
      <script type="text/vbscript">
     
      for $x in doc("Books.xml")/bookstore/book
      where $x/price>30
      order by $x/title
      return $x/title

      'CAN YOU PLEASE PROVIDE ME CODE THAT OUTPUTS THE return VALUE TO BROWSER ?

      </script>
     
      </body>
</html>

Thanks
0
 

Author Comment

by:kishore_peddi
ID: 20337364
BTW: I have tried like this:

<html>
      <body>
     
      for $x in doc("Books.xml")/bookstore/book
      where $x/price>30
      order by $x/title
      return $x/title
     
      </body>
</html>

Thanks
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 20337569
As I said, you can't do this in a browser
there simply is no XQuery support in a browser
so I can't make your example work
you need a special XQuery processor for that
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question