Difference between XPath, XQuery and XPointer
Asked Answered
R

4

71

What is the difference between XPath, XQuery and XPointer? As far as I know, XQuery is an extended version of XPath. I have some basic knowledge of XPath. Is there any feature available in XPath which is not in XQuery? Yesterday, I heard a new word, XPointer. I am confused. Which language is used for which purpose?

Rhymester answered 29/5, 2009 at 5:42 Comment(0)
S
65

Though the answer by Matthew gives a good first impression, there is a lot more to tell about the mentioned standards, and there are many more that are related. There is a nice article from the XML Holland user group magazine made available online, that tells a lot about the history of XQuery, and takes various of these standards into perspective. The first part is quite relevant here:

XQuery stands for XML Query Language. That already tells the essence. It is a language to select subsets and substructures from a large set of XML files. The result can be manipulated into something that is suitable to be used in, for example, a subsequent process, or to show in a web browser. XPath is used a lot in XQuery.

All XML standards have their own scope. I’ll name a few. XSLT is a language for transforming XML into some other format. XPointer is an extension of XPath to address nodes more accurately within XML fragments or even subparts of nodes. XLink is a standard to define relationships. XInclude is a standard to compose multiple pieces of XML into one using for instance XLink relationships. And XProc is a standard with which can be described how XML documents should be processed to get to a desired end result. It is expressed itself in XML, and describes the process step by step, also called XML Pipelines. Within XProc you use a.o. XQuery, XSLT, and XInclude languages (and thus indirectly XPath, XPointer and XLink as well) to express what needs to be done exactly within each step.

All these standards are tied together. They are related, and depend on each other. The overlap between some of the mentioned XML standards is summarized quite well in the next image that you can also find at W3Schools:

What is XPath

Full article can be found here: https://grtjn.blogspot.com/2011/10/xquery-novelties-revisited.html

HTH!

Sosthina answered 18/12, 2013 at 9:10 Comment(1)
In addition to the above, Querying XML was just the start for XQuery. Since its inception additional standards have been defined, like XQuery Full-Text, and XQuery Update Facility, to make it even more versatile than it already is on its own. Though a little dated by now, the above referenced article goes through most of these..Sosthina
U
67

Wikipedia is a good place to start for questions like this. Generally, XPath is a language used to succinctly pinpoint exact XML nodes in a DOM. XQuery is a superset of XPath that also provides FLWOR syntax, which is SQL-like. Finally, XPointer includes XPath, but also provides a simpler position-based addressing scheme.

Of course, you can always read the W3C specs for full details.

Unvalued answered 29/5, 2009 at 5:58 Comment(0)
S
65

Though the answer by Matthew gives a good first impression, there is a lot more to tell about the mentioned standards, and there are many more that are related. There is a nice article from the XML Holland user group magazine made available online, that tells a lot about the history of XQuery, and takes various of these standards into perspective. The first part is quite relevant here:

XQuery stands for XML Query Language. That already tells the essence. It is a language to select subsets and substructures from a large set of XML files. The result can be manipulated into something that is suitable to be used in, for example, a subsequent process, or to show in a web browser. XPath is used a lot in XQuery.

All XML standards have their own scope. I’ll name a few. XSLT is a language for transforming XML into some other format. XPointer is an extension of XPath to address nodes more accurately within XML fragments or even subparts of nodes. XLink is a standard to define relationships. XInclude is a standard to compose multiple pieces of XML into one using for instance XLink relationships. And XProc is a standard with which can be described how XML documents should be processed to get to a desired end result. It is expressed itself in XML, and describes the process step by step, also called XML Pipelines. Within XProc you use a.o. XQuery, XSLT, and XInclude languages (and thus indirectly XPath, XPointer and XLink as well) to express what needs to be done exactly within each step.

All these standards are tied together. They are related, and depend on each other. The overlap between some of the mentioned XML standards is summarized quite well in the next image that you can also find at W3Schools:

What is XPath

Full article can be found here: https://grtjn.blogspot.com/2011/10/xquery-novelties-revisited.html

HTH!

Sosthina answered 18/12, 2013 at 9:10 Comment(1)
In addition to the above, Querying XML was just the start for XQuery. Since its inception additional standards have been defined, like XQuery Full-Text, and XQuery Update Facility, to make it even more versatile than it already is on its own. Though a little dated by now, the above referenced article goes through most of these..Sosthina
W
17

Well, I think XQuery is something worth to be distinguished. XPath and XPointer are almost the same and are used for XML nodes selection. XQuery on the other hand is quite a big extension of XPath. For example it gives possibility of declaring custom functions. So it's more something like programming language, which works natively with XML. You can check out some samples here: embedding-xquery-in-java

Regards

Wirth answered 23/1, 2010 at 19:11 Comment(0)
S
7

XPath is intentionally limited to reading existing nodes.

As XSLT, XQuery can create nodes. It can also update nodes (with XQuery Update Facility).

From my XQuery implementor point of view ;-)

Sporogenesis answered 8/7, 2016 at 6:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.