Changes

Jump to navigation Jump to search
4 bytes added ,  18:39, 1 December 2023
m
Text replacement - "syntaxhighlight" to "pre"
The namespace for serialization parameters is statically bound to the {{Code|output}} prefix. This means that it need not (but may) be declared in the query prolog:
<syntaxhighlight pre lang="'xquery"'>
declare namespace output = 'http://www.w3.org/2010/xslt-xquery-serialization';
declare option output:method 'text';
<xml>Hi there</xml>
</syntaxhighlightpre>
Due to the wide range of ways how parameters can be supplied, we deliberately ignored one rule of the specification, which requires non-official features to be defined in a non-null namespace URI. In the following, we will indicate which features are specific to our implementation.
| Adds leading whitespaces to make the output more readable.
| {{Code|yes}}, {{Code|no}}
| {{Code|no}} {{Announce|Default changed with Version 10}}
|- valign="top"
| {{Code|cdata-section-elements}}
| List of elements to be output as CDATA, separated by whitespaces.<br />Example: {{Code|&lt;text&gt;&lt;![CDATA[ &lt;&gt; ]]&gt;&lt;/text&gt;}}
| ''string''
|
|- valign="top"
| {{Code|omit-xml-declaration}}
| Omits the XML declaration, which is serialized before the actual query result<br />Example: <code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</code>
| {{Code|yes}}, {{Code|no}}
| {{Code|yes}}
|- valign="top"
| {{Code|doctype-system}}
| Introduces the output with a document type declaration and the given system identifier.<br />Example: {{Code|&lt;!DOCTYPE x SYSTEM "entities.dtd"&gt;}}
| ''string''
|
|- valign="top"
| {{Code|doctype-public}}
| If {{Code|doctype-system}} is specified, adds a public identifier.<br />Example: {{Code|&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "<nowiki>http://www.w3.org/TR/html4/strict.dtd</nowiki>"&gt;}}
| ''string''
|
| ''string''
| {{Code|application/xml}}
|- valign="top"
| {{Code|parameter-document}}
| Parses the value as XML document with additional serialization parameters (see the [https://www.w3.org/TR/xslt-xquery-serialization-31/#serparams-in-xdm-instance Specification] for more details and examples).
| ''string''
|
|- valign="top"
| {{Code|use-character-maps}}
| Defines character mappings. If mappings are supplied as a single string, keys and values are separated by the equal sign, and multiple pairs are separated by commas. Separators that are to be defined as keys or values can be encoded as entities.<br />Example: <code>A=alpha,B=beta</code>
| ''string''
|
|- valign="top"
| {{Code|escape-uri-attributes}}
| Escapes URI information in certain HTML attributes<br />Example: <code>&lt;a&nbsp;href="%C3%A4%C3%B6%C3%BC"&gt;äöü&lt;a&gt;</code>
| {{Code|yes}}, {{Code|no}}
| {{Code|no}}
|- valign="top"
| {{Code|include-content-type}}
| Inserts a {{Code|meta}} content-type element into the head element if the result is output as HTML<br />Example: <code>&lt;head&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;&lt;/head&gt;</code>. The head element must already exist or nothing will be added. Any existing {{Code|meta}} content-type elements will be removed.
| {{Code|yes}}, {{Code|no}}
| {{Code|yes}}
|}
 
=Query Prolog Parameters=
 
The following parameters can only be specified in the query prolog (see [https://www.w3.org/TR/xquery-31/#id-serialization XQuery: Specification] for more details and examples):
 
{| class="wikitable sortable" width="100%"
|- valign="top"
! width="140" | Parameter
! Description
! Allowed
! Default
|- valign="top"
| {{Code|parameter-document}}
| Parses the value as an XML document with additional serialization parameters.
| ''string''
|
|}
The {{Code|csv}} and {{Code|json}} parameters are supplied with a list of options. Option names and values are combined with <code>=</code>, several options are separated by <code>,</code>:
<syntaxhighlight pre lang="'xquery"'>
declare option output:method "csv";
declare option output:csv "header=yes, separator=semicolon";
</record>
</csv>
</syntaxhighlightpre>
If {{Code|fn:serialize}} is called, output-specific parameters can be supplied via nested options:
<syntaxhighlight pre lang="'xquery"'>
serialize(
<csv>
}
)
</syntaxhighlightpre>
'''Result''':
<syntaxhighlight pre lang="xml">
Name;City
John;Newton
Jack;Oldtown
</syntaxhighlightpre>
=Character mappings=
'''Example query''':
<syntaxhighlight pre lang="'xquery"'>
declare option output:parameter-document "map.xml";
<x>&amp;#xA0;</x>
</syntaxhighlightpre>
'''Example parameter-document''':
<syntaxhighlight pre lang="xml">
<serialization-parameters
xmlns="http://www.w3.org/2010/xslt-xquery-serialization">
</use-character-maps>
</serialization-parameters>
</syntaxhighlightpre>
=Changelog=
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu