XQuery
Priscilla Walmsley (pwalmsley@datypic.com)
ISBN: 0596006349
1st edition, , O'Reilly Media, Inc.
Chapter 2: XQuery foundations
declare boundary-space preserve; declare namespace prod = "http://datypic.com/prod"; declare variable $catalog := doc("catalog.xml")//catalog; <firstResult>{count($catalog/product)}</firstResult>, <prod:secondResult>{$catalog/product/number}</prod:secondResult>
<catalog xmlns="http://datypic.com/cat"> <product dept="MEN" xmlns="http://datypic.com/prod"> <number>784</number> <name language="en">Cotton Dress Shirt</name> <colorChoices>white gray</colorChoices> <desc>Our <i>favorite</i> shirt!</desc> </product> </catalog>
<prod:product xmlns:prod="http://datypic.com/prod"> <prod:number>563</prod:number> <prod:name language="en">Floppy Sun Hat</prod:name> </prod:product>
declare namespace prod = "http://datypic.com/prod"; for $product in doc("prod_ns.xml")/prod:product return $product/prod:name