Serialization Parameters
This page describes the full set of serialization parameters supported by XmlPrime.
This topic contains the following sections.
Overview
The XSLT 2.0 and XQuery 1.0 Serialization (Second Edition) specification describes a large set of serialization parameters which determine the behaviour of serialization. XmlPrime adds some extra implementation-specific parameters which add some new features to the serializer. This document lists all the serialization parameters supported by XmlPrime, and all the values that are supported by these parameters.
As of version 2.2, XmlPrime has support for serialization parameters specified in XSLT and XQuery Serialization 3.0.
Declaring serialization parameters
Serialization parameters can be declared in several ways depending on how serialization is invoked.
Declaring serialization parameters in code
If serialization is being invoked from the API then the
serialization parameters are set using the
XdmWriterSettingsXdmWriterSettingsXdmWriterSettings
class. Each parameter is equivalent to a property on this class,
as described below; but the values can also be set by name using
the
SetParameter (XmlQualifiedName, string)SetParameter (XmlQualifiedName, String)SetParameter (XmlQualifiedName^, String^)
and SetParameter (XmlQualifiedName, string, IXmlNamespaceResolver)SetParameter (XmlQualifiedName, String, IXmlNamespaceResolver)SetParameter (XmlQualifiedName^, String^, IXmlNamespaceResolver^)
methods. The code snippet below shows two different ways of
setting the indent
property to
yes.
XdmWriterSettings serializationSettings = new XdmWriterSettings(); // setting the value directly with a property settings.Indent = true; // setting the value by name and value settings.SetParameter(new XmlQualifiedName("indent"), "yes");
The serialization settings may also be read from a serialization parameters document, using the ParameterDocumentParameterDocumentParameterDocument method.
Declaring serialization parameters in XQuery
XQuery serialization parameters can also be set within a query
using declare option
declarations.
These override any serialization settings specified by the
XQuerySettings.SerializationSettingsXQuerySettings.SerializationSettingsXQuerySettings::SerializationSettings
property. The post-compilation serialization settings are
exposed by the
XQuery.SerializationSettingsXQuery.SerializationSettingsXQuery::SerializationSettings property.
As of version 2.2, XmlPrime supports the setting of serialization parameters as defined in section 2.2.4 Serialization of XQuery 3.0.
To set XmlPrime-specific serialization parameters, an option declaration with the namespace http://www.xmlprime.com/serialization is treated as a serialization parameter declaration. If the local name of the option corresponds to a standard serialization parameter then the serialization parameter is assumed to be in no namespace; otherwise the parameter is assumed to be in the http://www.xmlprime.com/serialization namespace. QName values are specified as lexical QNames, and are resolved against the in-scope namespaces.
The following example illustrates how to set the
indent
property to
yes using
declare option
within an XQuery program.
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization"; declare option output:indent "yes";
Declaring serialization parameters in XSLT
XSLT serialization parameters can also be set within a transformation
using xsl:output
or xsl:result-document
declarations.
These override any serialization settings specified by the
XsltSettings.SerializationSettingsXsltSettings.SerializationSettingsXsltSettings::SerializationSettings
property. The post-compilation serialization settings are
exposed by the XsltSettings.SerializationSettingsXsltSettings.SerializationSettingsXsltSettings::SerializationSettings property.
To set XmlPrime-specific serialization parameters, use extension attributes in the namespace
http://www.xmlprime.com/serialization on xsl:output
or xsl:result-document
elements.
The following example illustrates how to set the
new-line-chars
property to a single linefeed (LF) character. using
xsl:output
within an XSLT program.
<xsl:output xmlns:xps="http://www.xmlprime.com/serialization" xps:new-line-chars="�A;" />
Declaring serialization parameters on the command line
If a query is run on the command line with the
XQuery.exe
tool, then serializationde
parameters can be set by adding !parameter=value
to the command line. QName values can be specified in Clark
notation. The following example shows how to set the
indent
property to yes,
and also shows how to set the (implementation specific)
serialization:conformance-level
property
to document.
xquery query.xq !indent=yes !{http://www.xmlprime.com/serialization}conformance-level=document
Serialization parameters can also be set from a serialization parameter document as in the following example. For more information about serialization parameter documents, see the Schema for Serialization Parameters in XSLT and XQuery Serialization 3.0.
xquery query.xq !parameter-document="serialization.xml"
Serialization parameters
The following section lists the full set of serialization settings supported by XmlPrime.
In this section the prefix ser is assumed to be bound to http://www.xmlprime.com/serialization.
Standard serialization parameters
The following parameters are defined in the XSLT 2.0 and XQuery 1.0 Serialization (Second Edition) and XSLT and XQuery Serialization 3.0 specifications. The table below specifies the name of each parameter, the equivalent property on the XdmWriterSettingsXdmWriterSettingsXdmWriterSettings class, the default value of the property, and the supported values that the property can take.
Built in serialization parameters
Name | Corresponding property | Default value | Description |
---|---|---|---|
byte-order-mark
| ByteOrderMarkByteOrderMarkByteOrderMark | no | This can be set to either yes or no. This indicates whether the serialized document should start with a Unicode Byte Order Mark. If this does not apply to the specified encoding, then it is ignored. |
cdata-section-elements
| CDataSectionElementsCDataSectionElementsCDataSectionElements | (empty) | This is set to a list of qualified element names, separated by a single space. The text content of any element with a name in this list is serialized as a CDATA section. This parameter is ignored in the text and ser:canonical output modes, and used only for elements with non-null namespace in the html output mode. |
doctype-public
| DoctypePublicDoctypePublicDoctypePublic | (not set) |
This specifies the public document type to be serialized in
the document type declaration. This parameter is ignored
unless doctype-system has been set.
This parameter is ignored when method
is not set to xml or
xhtml. If method
is set to xml or xhtml
and doctype-public is not a valid
public identifier, then a SERE0003
error is raised when serialization is attempted.
|
doctype-system
| DoctypeSystemDoctypeSystemDoctypeSystem | (not set) |
Specifies the system document type to be used in the document
type declaration. Setting this property causes a document
type declaration to be serialized immediately before the first
element. If this property is not set then no document type
declaration is serialized. This parameter is ignored when
If |
encoding
| EncodingEncodingEncoding | UTF-8 |
Specifies the encoding to be used when serializing. The following encodings are supported: IBM037, IBM500, IBM1047, IBM273, IBM277, IBM280, IBM284, IBM285, IBM297, IBM871, iso-8859-1, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-9, iso-8859-13, iso-8859-15, us-ascii, utf-8, utf-16, utf-16BE, utf-16LE, utf-32, utf-32BE, utf-32LE, GB18030, unicodeFFFE and Windows-1252. These values are case-insensitive.
If
When serializing to a
TextWriterTextWriterTextWriter
this parameter is ignored, and the encoding specified by
EncodingEncodingEncoding
is used instead. This parameter is ignored when
|
escape-uri-attributes
| EscapeUriAttributesEscapeUriAttributesEscapeUriAttributes | yes |
This can be set to either yes or
no. In html and
XHTML output methods this setting indicates
that all attributes that must take URIs (for example the
href attribute on the
a tag) will have their values escaped
as is performed by the fn:escape-html-uri
function. If the method parameter is
not set to html or xhtml,
this parameter is ignored.
|
include-content-type
| IncludeContentTypeIncludeContentTypeIncludeContentType | no |
This can be set to either yes or
no. If
include-content-type is set to
yes, then in html and
XHTML output methods, the serializer should
add a meta element as the first child
of the head element specifying the
content type from the media-type
parameter, and with the encoding actually used. If the
method parameter is not set to
html or xhtml, this
parameter is ignored.
|
indent
| IndentIndentIndent | no |
This can be set to either yes or
no. If
indent is set to
yes, then extra whitespace may be added
to the document in order to make it easier to read, in
accordance with the rules specific to the current output
method. If the method parameter is
set to text or ser:canonical,
this parameter is ignored.
|
media-type
| MediaTypeMediaTypeMediaType | (not set) |
When the |
method
| MethodMethodMethod | xml |
Specifies the output mode. The supported output modes are
the standard output modes (xml,
xhtml, html and
text) as defined in the
specification, along with the implementation specific value
ser:canonical. If the value is not a
supported method then a Setting this parameter to ser:canonical indicates that the serialization process should produce canonical XML. |
normalization-form
| NormalizationFormNormalizationFormNormalizationForm | none |
Specifies the unicode normalization form. All text content in
the serialized document will be normalized with this
normalization form. The supported normalization forms are
none, NFC,
NFD, NFKC,
NFKD and fully-normalized
as specified in the
specification. These values are case-insensitive. If the
value is not a supported method and the
|
omit-xml-declaration
| OmitXmlDeclarationOmitXmlDeclarationOmitXmlDeclaration | no |
This parameter takes one of the enumerated values
yes or no. This
parameter indicates whether the xml declaration should be
omitted. If the method parameter is
not set to html or xhtml,
this parameter is ignored.
|
standalone
| StandaloneStandaloneStandalone | omit |
This parameter takes one of the enumerated values
yes or no. If
|
suppress-indentation
| SuppressIndentationSuppressIndentationSuppressIndentation | (empty) |
This is set to a list of qualified element names, separated by
a single space. Whitespace characters will not be added, elided or replaced in any element with a name
in this list. If the method parameter is
set to text or ser:canonical,
this parameter is ignored.
|
undeclare-prefixes
| UndeclarePrefixesUndeclarePrefixesUndeclarePrefixes | no |
This parameter takes one of the enumerated values
yes or no. If
|
version
| VersionVersionVersion | (not set) |
Specifies either the XML version (if the
If the version is not supported (XML version is not
1.0, HTML version is not
4.0 or 4.01 or the
Canonical XML version is not 1.0 then an
If this parameter is not set then the version is assumed to be
4.01 if the |
use-character-maps
| CharacterMappingCharacterMappingCharacterMapping | (empty) |
Specifies a mapping from characters to strings.
Character maps allow specific characters that are serialized
to be replaced with a specific string of characters. No
escaping is applied to the string that is substituted and so
this mechanism can be used to introduce arbitrary markup
in the serialized output. This parameter can only be set with the
CharacterMappingCharacterMappingCharacterMapping
property. This parameter is ignored when
method is set to
ser:canonical.
|
Implementation-defined parameters
The following parameters are specific to XmlPrime, and allow for further customization of the serialization specification. All the parameters below are in the namespace http://www.xmlprime.com/serialization. The table below specifies the name of each parameter, the equivalent property on the XdmWriterSettingsXdmWriterSettingsXdmWriterSettings class, the default value of the property, and the supported values that the property can take.
Implementation-specific serialization parameters
Name | Corresponding property | Default value | Description |
---|---|---|---|
ser:character-reference-style
| CharacterReferenceStyleCharacterReferenceStyleCharacterReferenceStyle | hexadecimal |
This parameter takes one of the enumerated values
decimal or hexadecimal. This
parameter specifies the style in which character references
are encoded. If the method parameter is
set to text or
ser:canonical, this parameter is ignored.
|
ser:check-namespaces
| CheckNamespacesCheckNamespacesCheckNamespaces | auto |
This parameter takes one of the enumerated values
check-absolute, none
or auto. If this is set to
check-absolute then a
If |
ser:conformance-level
| ConformanceLevelConformanceLevelConformanceLevel | auto |
This parameter takes one of the enumerated values
document, fragment
or auto. If this is set to
document then a
If this is set to fragment and
If |
ser:indentation-characters
| IndentationCharactersIndentationCharactersIndentationCharacters | (two spaces) |
This property specifies the characters that are used for
indentation. If the method parameter
is set to text or
ser:canonical, or if the
indent parameter is not set to
yes then this parameter is ignored.
|
ser:new-line-chars
| NewLineCharsNewLineCharsNewLineChars | Environment.NewLineEnvironment.NewLineEnvironment::NewLine |
Any newline ( ) characters serialized, and any new
lines introduced are replaced by the value of this property.
If the method parameter
is set to ser:canonical then this parameter
is ignored.
|