Chapter 22. Additional XQuery-Related Standards

This book describes the core features of the XQuery 1.0 language and its associated built-in functions and data model. There are several peripheral standards that complement, but are not central to, the XQuery 1.0 language. These standards, which are in varying stages of completion, include Serialization, XQueryX, XQuery Updates, Full-Text search, and XQJ.

Serialization

Serialization is the process of writing the results of a query out to XML syntax. (Implementations are not required to support serialization at all, but most do.) In your query, you construct (or select) a number of XML elements and attributes to include in the results. These results conform to the data model described in Chapter 2. However, the data model does not define the details of the XML syntax and format to be used. Certain syntactic differences may appear when working with different implementations, such as the encoding used, whether an XML declaration is included at the beginning of a document, or whether the results are indented.

Some of these syntactic differences can be controlled using serialization parameters, which are listed in Table 22-1. Some implementations will allow you to specify values for some of the serialization parameters; this is covered further in the section entitled "Specifying Serialization Parameters" in Chapter 23.

For more information on serialization, including a detailed description of the effect of each serialization parameter, see XSLT 2.0 and XQuery 1.0 Serialization at http://www.w3.org/TR/xslt-xquery-serialization.

Table 22-1. Serialization parameters

Parameter name

Description

method

The type of output, namely xml, xhtml, html, or text.

byte-order-mark

yes/no; default is implementation-defined. Use yes if you would like a byte order mark to precede the serialized results.

cdata-section-elements

An optional list of qualified element names; the default is a zero-item list. Add an element name to the list if you would like its contents to be enclosed in a CDATA section in the output.

doctype-public

A public identifier to be included in a document type declaration.

doctype-system

A system identifier to be included in a document type declaration.

encoding

The encoding to be used for the results. The default is either UTF-8 or UTF-16 (whichever one is implementation-defined). Implementations are required to support at least these two values.

escape-uri-attributes

yes/no; default is implementation-defined. Applies only to html and xhtml output types. Use yes if you want to perform URI escaping on attributes that are defined in (X)HTML to be URIs, such as href and src.

include-content-type

yes/no; default is implementation-defined. Applies only to html and xhtml output types. Use yes if you want to include a meta element that specifies the content type, as in:

<meta http-equiv="Content-Type" content="text/html;
charset=EUC-JP" />.

indent

yes/no; default is no. Use yes if you want to pretty-print the results, i.e., put line breaks and indenting spaces between elements.

media-type

The media type (MIME type); default is implementation-defined.

normalization-form

One of NFC, NFD, NFKC, NFKD, fully-normalized, or an implementation-defined value. Default is implementation-defined. Unicode normalization is discussed in Chapter 17.

omit-xml-declaration

yes/no; default is implementation-defined. Use yes if you do not want an XML declaration in your results.

standalone

yes, no or omit; default is implementation-defined. The value of the standalone parameter of the XML declaration. Use omit to not include the standalone parameter.

undeclare-prefixes

yes/no; default is no. When using XML 1.1, use yes to instruct the processor to insert namespace "undeclarations," e.g., xmlns:dty="", to indicate that a namespace declaration is no longer in scope. This is rarely, if ever, necessary.

use-character-maps

Default is an empty list. A list of character maps that can be used to perform character substitution on the results.

version

Default is implementation-defined, generally 1.0 or 1.1 for XML—the version of XML (or HTML if the output method is html).

Errors occasionally occur during serialization. They may be the result of conflicting serialization parameters or a query that returns results that cannot be serialized. For example:

doc("catalog.xml")//@dept

is a perfectly valid query, but it will return a sequence of attribute nodes. This cannot be serialized and will raise an error. Serialization errors all start with the letters SE and are listed in Appendix C.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.196.103