Returns a string object encapsulating the receiver’s XML in canonical form.
- macOS 10.4+
trueto preserve comments,
Be sure to set the input option
node for true canonical form. The canonical form of an XML document is defined by the World Wide Web Consortium at
http://www. Generally, if two documents with varying physical representations have the same canonical form, then they are considered logically equivalent within the given application context. The following list summarizes most key aspects of canonical form as defined by the W3C recommendation:
Encodes the document in UTF-8.
Normalizes line breaks to “#xA” on input before parsing.
Normalizes attribute values in the manner of a validating processor.
Replaces character and parsed entity references with their character content.
Replaces CDATA sections with their character content.
Removes the XML declaration and the document type declaration (DTD).
Converts empty elements to start-end tag pairs.
Normalizes whitespace outside of the document element and within start and end tags.
Retains all whitespace characters in content (excluding characters removed during line-feed normalization).
Sets attribute value delimiters to quotation marks (double quotes).
Replaces special characters in attribute values and character content with character references.
Removes superfluous namespace declarations from each element.
Adds default attributes to each element.
Imposes lexicographic order on the namespace declarations and attributes of each element.