Version 0.9  What is XML4Ada95?  Installation  How-To  API  Download 

COUNTER
counter


Interface Serializer

DOMWriter provides an API for serializing (writing) a DOM document out in an XML document.

During serialization of XML data, namespace fixup is done when possible. Serializer accepts any node type for serialization. For nodes of type Document or Entity, well formed XML will be created if possible. The serialized output for these node types is either as a Document or an External Entity, respectively, and is acceptable input for an XML parser. For all other types of nodes the serialized form is not specified, but should be something useful to a human for debugging or diagnostic purposes. Note: rigorously designing an external (source) form for stand-alone node types that don't already have one defined in seems a bit much to take on here.
Within a Document or Entity being serialized, Nodes are processed as follows Documents are written including an XML declaration and a DTD subset, if one exists in the DOM. Writing a document node serializes the entire document. Entity References nodes are serializes as an entity reference of the form "&entityName;") in the output. Child nodes (the expansion) of the entity reference are ignored. CDATA sections containing content characters that can not be represented in the specified output encoding are handled according to the "split-cdata-sections" feature. If the feature is true, CDATA sections are split, and the unrepresentable characters are serialized as numeric character references in ordinary content. The exact position and number of splits is not specified. If the feature is false, unrepresentable characters in a CDATA section are reported as errors. The error is not recoverable - there is no mechanism for supplying alternative characters and continuing with the serialization. All other node types (DOMElement, DOMText, etc.) are serialized to their corresponding XML source form.
Within the character data of a document (outside of markup), any characters that cannot be represented directly are replaced with character references. Occurrences of '<' and '&' are replaced by the predefined entities &lt; and &amp. The other predefined entities (&gt, &apos, etc.) are not used; these characters can be included directly. Any character that can not be represented directly in the output character encoding is serialized as a numeric character reference.
Attributes not containing quotes are serialized in quotes. Attributes containing quotes but no apostrophes are serialized in apostrophes (single quotes). Attributes containing both forms of quotes are serialized in quotes, with quotes within the value represented by the predefined entity &quot;. Any character that can not be represented directly in the output character encoding is serialized as a numeric character reference.
Within markup, but outside of attributes, any occurrence of a character that cannot be represented in the output character encoding is reported as an error. An example would be serializing the element <LaCaņada/> with the encoding="us-ascii".
When requested by setting the normalize-characters feature on Serializer, all data to be serialized, both markup and character data, is W3C Text normalized according to the rules defined in . The W3C Text normalization process affects only the data as it is being written; it does not alter the DOM's view of the document after serialization has completed.
Namespaces are fixed up during serialization, the serialization process will verify that namespace declarations, namespace prefixes and the namespace URIs associated with Elements and Attributes are consistent. If inconsistencies are found, the serialized form of the document will be altered to remove them. The algorithm used for doing the namespace fixup while seralizing a document is a combination of the algorithms used for lookupNamespaceURI and lookupNamespacePrefix.
Any changes made affect only the namespace prefixes and declarations appearing in the serialized data. The DOM's view of the document is not altered by the serialization operation, and does not reflect any changes made to namespace declarations or prefixes in the serialized output.
Serializers have a number of named features that can be queried or set. The name of Serializer features must be valid XML names. Implementation specific features (extensions) should choose an implementation dependent prefix to avoid name collisions.
A complete list of features can be found in the Xerces documentation.


get_newLine set_newLine writeToString writeToFile writeToStdOut canSetFeature setFeature getFeature

e-Mail: denny@nodix.de

design shareright © 2002 Phlash  
inhalt © 2003-04 Zdenko Denny Vrandecic  
last update: 14.01.2004 website created by XML4Ada95 DocGen