17.07.2015 Views

The Omedian Technical Architecture - Red Gate Software

The Omedian Technical Architecture - Red Gate Software

The Omedian Technical Architecture - Red Gate Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Page 14 of 90Chapter 2: SQL Server XML Crib SheetXQuery has been around for a while. It evolved from an XML query language called Quilt, which in turn wasderived from XML Path Language (XPath) version 1.0, SQL, and XQL.XQuery has similarities with SQL, but is by no means the same. SQL is a more complete language. <strong>The</strong> SELECTstatement is similar to XQuery's language, but XQuery has to deal with a more complex data model.<strong>The</strong> XQuery specification currently contains syntax and semantics for querying, but not for modifying XMLdocuments, though these are effected by extensions to XQuery, collectively called the XML Data ManipulationLanguage (XML DML). This allows you to modify the contents of the XML document. With XML DML onecan insert child or sibling nodes into a document, delete one or more nodes, or replace values in nodes.Microsoft thoughtfully provided extensions that allow T-SQL variables and columns to be used to bind relationaldata inside XML data. Server 2005 adds three keywords: insert, update, and delete. Each of these is used withinthe modify() method of the XML data type.<strong>The</strong> XDM that XQuery uses is unlike the Document Object Model (DOM). Each branch (or "node") of theXDM tree maintains a set of attributes describing the node. In the tree, each node has an XML node type, XDMdata type information, node content (string and typed representations), parent/child information, and possiblysome other information specific to the node type.FLWORXQuery's FLWOR expressions (For, Let, Where, Order by, and Return) iterates XML nodes using the 'for'clause, limits the results using the 'where' clause, sorts the results using the 'order by' clause, and returns theresults via the 'return' clause. <strong>The</strong>se constructs greatly extend the versatility of XQuery, making it comparable toSQLXPathXPath was designed to navigate an XML document to retrieve the document's elements and attributes. It alsoprovides basic facilities for manipulation of strings, numbers and Booleans. It represents the document as a treeof nodes, and allows reference to nodes by absolute or relative paths. One can specify criteria for the nodes thatare returned in square brackets.XML Template QueriesAn XML template query is an XML document with one or more TSQL or XPath queries embedded in it,allowing you to query an XML document. <strong>The</strong> results can be transformed with an XSLT stylesheet. Templatequeries are used in client code to update SQL Server data. <strong>The</strong>y are templates with attributes and elements thatspecify data requiring updating and how that is to be done.UpdateGramAn UpdateGram is an XML template that is used to insert, update or delete data in a database. It contains animage of the data before and after the required modification. It is usually transmitted to the server by a clientapplication. Each element usually represents one record in a table. <strong>The</strong> data is 'mapped' either implicitly orexplicitly. One can pass parameters to them.DiffGramThis is an XML document format that is used to synchronise offline changes in data with a database server. It isvery similar to an UpdateGram, but is less complex. It is generally used for 'persisting' the data in data objects.Page 14Chapter 2: SQL Server XML Crib Sheet

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!