views:

1542

answers:

4

I know how to find what I need from XML using XPath. The syntax takes a little getting used to, but it is quite powerful. I'm interested in learning XQuery also, but the SQL like syntax seems awkward. Even so, if it can provide not just a select equivalent, but also update, insert, and delete as SQL does, I will forgive all awkwardness.

So, does XQuery have equivalents to Update, Insert, and Delete as well as Select?

Does XPath have these equivalents that I have overlooked?

+4  A: 

take a look at the XQuery Update Facility: http://www.w3.org/TR/xquery-update-10/ or check out the use-cases: http://www.w3.org/TR/xquery-update-10-use-cases/ or check out the XML Query working group page: http://www.w3.org/XML/Query/

+2  A: 

XPath is a language for addressing parts of an XML document. So it cannot have any DML statement. It is select statement by definition.

horseman
+9  A: 

No. None of XPath or XQuery has SQL-like update/insert/delete functionality.

You need to look for an implementation of the "XQuery 1.0 Update Facility".

At this moment (Nov. 2008), three such are known:

  1. SaxonSA XSLT and XQuery Processor — by Michael Kay; Supported since version 9.1, but only in the commercial version.
  2. MonetDB/XQuery - An open source XQuery processor on top of the MonetDB relational database system.
  3. XQilla - An open source (ASL2.0) XQuery processing library with support for the latest XQuery Update features. XQilla is written in C++ and includes a command line executable shell to execute queries against XML content stored on a local filesystem. This library is actively developed and part of a supported Oracle product, Berkeley DB XML.
Dimitre Novatchev
+1  A: 

In SQL Server 2005/8 the extension of XQuery is called XML DML, and supports data modification using the replace value of statement.

devio