Solved

Why XQUERY is needed when XPATH is already there ?

Posted on 2007-11-22
6
395 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
  • 4
  • 2
6 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:kishore_peddi
Comment Utility
<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
Comment Utility
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 500 total points
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
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…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now