XQuery Helena Galhardas DEI IST. Agenda XPath – exercício XQuery.
XQuery Extensions
-
Upload
aaron-buma -
Category
Software
-
view
814 -
download
0
Transcript of XQuery Extensions
XQuery Extensions
Presentation by Aaron BumaDevelopment DBA
Session Overview
• Take a look at:– .query ()– .value()– .exists()– .modify()– .nodes()– FLWOR
• See them in action
.query() Method
• Extracts XML fragments
.value() Method
• Extracts a value(s) from the node, [n] is required
.exists() Method
• Determines if node exists, returns a 1 or a 0
.modify() Method
• Only works with an UPDATE statement• Updates the XML value in directly in the XML• You can insert, replace and delete:– Nodes, values or attributes
Dissecting the .modify() Method
• Syntax:– “replace value of ”+(node location)+“ with (“+value+”)”
• Replace value the first occurrence of “name” nodes, where the category is “PARTS”
• With the value “BOLTS-SHORT”
Dissecting the .modify() Method
• Where, for all name nodes with the “category” attribute is “PARTS”
• the node value is “BOLTS”
Shredding with .nodes()
• Pull XML/values from an XML Stream like a table• Syntax:– Define a node level– Declare a table and Column Collection
– Reference the ‘columns’ with XQuery
FLWOR Expressions
• Used for iterating over XML, aka a “for loop”.– Only For and Return are required
• For - Establishes a variable name for current level• Let – Additional variables• Where – Filtering on any of the defined variables• Order By – Ordering the output set• Return – The format of the output
DEMOS
Review
• .query, .value(), .exists()• .modify() - Insert, Replace, Delete• Shredding with .nodes()• FLWOR Expressions
Presentation Recording, Slides and Scripts– Available at: http://www.aaronbuma.com/2015/10/xquery-extensions/