XQuery
Priscilla Walmsley (pwalmsley@datypic.com)
ISBN: 0596006349
1st edition, , O'Reilly Media, Inc.
Chapter 12: Queries, prologs and modules
xquery version "1.0"; declare default element namespace "http://datypic.com/cat"; declare boundary-space preserve; declare default collation "http://datypic.com/collation/custom"; declare namespace ord = "http://datypic.com/ord"; import schema namespace prod="http://datypic.com/prod" at "http://datypic.com/prod.xsd"; declare function local:getProdNums ($catalog as element()) as xs:integer* {for $prod in $catalog/product return xs:integer($prod/number)};
<title>Order Report</title>, (for $item in doc("order.xml")//item order by $item/@num return $item)
module namespace strings = "http://datypic.com/strings"; declare variable $strings:maxStringLength := 32; declare function strings:trim($arg as xs:string?) as xs:string? { "function body here" };