XQuery
Priscilla Walmsley (pwalmsley@datypic.com)
ISBN: 1491915103
2nd edition, , O'Reilly Media, Inc.
Chapter 13: Inputs and Outputs
Please note that the book contains many inline examples and informal tables that are not provided here.
xquery version "3.0"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare namespace prod = "http://datypic.com/prod"; declare option output:method "xml"; declare option output:indent "yes"; declare option output:cdata-section-elements "prod:desc prod:name"; declare option output:omit-xml-declaration "yes";
xquery version "3.0"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare option output:parameter-document "parameters.xml";
<output:serialization-parameters xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization" xmlns:prod="http://datypic.com/prod"> <output:method value="xml"/> <output:version value="1.0"/> <output:indent value="yes"/> <output:cdata-section-elements value="prod:desc prod:name"/> <output:use-character-maps> <output:character-map character="«" map-string="<%"/> <output:character-map character="»" map-string="%>"/> </output:use-character-maps> </output:serialization-parameters>
<xquery version "3.1"; declare namespace prod = "http://datypic.com/prod"; let $map := map { "method": "xml", "version": "1.0", "indent": true(), "cdata-section-elements": (xs:QName("prod:desc"),xs:QName("prod:name")), "use-character-maps": map { "«":"<%", "»":">%"> } } let $element := <prod:name>Fleece Pullover</prod:name> return serialize($element,$map)