Difference between revisions of "Serialization"

From BaseX Documentation
Jump to navigation Jump to search
Line 18: Line 18:
 
! Parameter
 
! Parameter
 
! Description
 
! Description
! Restrictions
+
! Value
 
! Default
 
! Default
 
! Examples
 
! Examples
Line 41: Line 41:
 
|- valign="top"
 
|- valign="top"
 
| <code>cdata-section-elements</code>
 
| <code>cdata-section-elements</code>
| List of elements to be output as CDATA, separated by whitespaces.
+
| List of elements to be output as CDATA, separated by whitespaces (e.g.: <code>&lt;text&gt;&lt;![CDATA[ &lt;&gt; ]]&gt;&lt;/text&gt;</code>).
 
|  
 
|  
 
|  
 
|  
Line 53: Line 53:
 
|- valign="top"
 
|- valign="top"
 
| <code>standalone</code>
 
| <code>standalone</code>
| Prints or omits the "standalone" attribute in the XML declaration, which states if the document has
+
| Prints or omits the "standalone" attribute in the XML declaration, which states if the document has any external markup declarations.
[http://www.w3.org/TR/REC-xml/#sec-rmd external markup declarations].
 
 
| <code>yes,no,omit</code>
 
| <code>yes,no,omit</code>
 
| <code>omit</code>
 
| <code>omit</code>
 
| <code>standalone=yes</code>
 
| <code>standalone=yes</code>
 +
|- valign="top"
 +
| <code>doctype-system</code>
 +
| Introduces the output with a document type declaration and the given system identifier.
 +
|
 +
|
 +
| <code>doctype-system=entities.dtd</code>
 +
|- valign="top"
 +
| <code>doctype-public</code>
 +
| If <code>doctype-system</code> is specified, adds a public identifier.
 +
|
 +
|
 +
| <code>doctype-public=-//W3C//DTD HTML 4.01//EN,<br />doctype-system=http://www.w3.org/TR/html4/strict.dtd</code>
 +
|- valign="top"
 +
| <code>undeclare-prefixes</code>
 +
| Undeclares prefixes in XML 1.1.
 +
| <code>yes,no</code>
 +
| <code>no</code>
 +
| <code>undeclare-prefixes=yes</code>
 +
|- valign="top"
 +
| <code>normalization-form</code>
 +
| Specifies a normalization form. BaseX supports Form C (<code>NFC<code>).
 +
| <code>NFC,none</code>
 +
| <code>NFC</code>
 +
| <code>normalization-form=none</code>
 +
|- valign="top"
 +
| <code>media-type</code>
 +
| Specifies the media type.
 +
|
 +
| <code>application/xml</code>
 +
| <code>media-type=text/plain</code>
 +
|- valign="top"
 +
| <code>use-character-maps</code>
 +
| Defines character mappings (not supported).
 +
|
 +
|
 +
|
 +
|- valign="top"
 +
| <code>byte-order-mark</code>
 +
| Prints a byte-order-mark before starting serialization.
 +
| <code>yes,no</code>
 +
| <code>no</code>
 +
| <code>byte-order-mark=yes</code>
 +
|- valign="top"
 +
| <code>escape-uri-attributes</code>
 +
| Escapes URI information in certain HTML attributes (e.g.: <code>&lt;a&nbsp;href="%C3%A4%C3%B6%C3%BC"&gt;äöü&lt;a&gt;)</code>.
 +
| <code>yes,no</code>
 +
| <code>no</code>
 +
| <code>escape-uri-attributes=yes, method=html</code>
 +
|- valign="top"
 +
| <code>include-content-type</code>
 +
| Includes a <code>meta</code> content-type element if the result is output as HTML (e.g.: &lt;head&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;&lt;/head&gt;).
 +
| <code>yes,no</code>
 +
| <code>no</code>
 +
| <code>include-content-type=yes, method=html</code>
 
|}
 
|}

Revision as of 02:13, 6 February 2011

Serialization parameters define how XQuery items and XML nodes are textually output, i.e., serialized. They have been formalized in the W3C XQuery Serialization 3.0 document. In BaseX, they can be specified in several ways:

Parameters

The following table gives a brief summary of all serialization parameters supported by BaseX. For details, please refer to official specification.

Parameter Description Value Default Examples
version XML Version. 1.0,1.1 1.0 version=1.0
encoding Encoding to be used for outputting the data. UTF-8 encoding=US-ASCII
indent Adjust whitespaces to make the output better readable. yes,no yes indent=no
cdata-section-elements List of elements to be output as CDATA, separated by whitespaces (e.g.: <text><![CDATA[ <> ]]></text>). cdata-section-elements=text
omit-xml-declaration Omits the XML declaration, which is serialized before the actual query result. yes,no yes omit-xml-declaration=no
standalone Prints or omits the "standalone" attribute in the XML declaration, which states if the document has any external markup declarations. yes,no,omit omit standalone=yes
doctype-system Introduces the output with a document type declaration and the given system identifier. doctype-system=entities.dtd
doctype-public If doctype-system is specified, adds a public identifier. doctype-public=-//W3C//DTD HTML 4.01//EN,
doctype-system=http://www.w3.org/TR/html4/strict.dtd
undeclare-prefixes Undeclares prefixes in XML 1.1. yes,no no undeclare-prefixes=yes
normalization-form Specifies a normalization form. BaseX supports Form C (NFC). NFC,none NFC normalization-form=none
media-type Specifies the media type. application/xml media-type=text/plain
use-character-maps Defines character mappings (not supported).
byte-order-mark Prints a byte-order-mark before starting serialization. yes,no no byte-order-mark=yes
escape-uri-attributes Escapes URI information in certain HTML attributes (e.g.: <a href="%C3%A4%C3%B6%C3%BC">äöü<a>). yes,no no escape-uri-attributes=yes, method=html
include-content-type Includes a meta content-type element if the result is output as HTML (e.g.: <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>). yes,no no include-content-type=yes, method=html