Canonical XML

Canonical XML

Canonical XML is a profile or subset of XML. Any XML document can be converted to Canonical XML, thus normalizing away specific kinds of minor differences while remaining an XML document. Because those specific differences are generally not considered to be "meaningful", converting to Canonical XML is a good way to determine whether two XML documents are logically "the same document" despite differences of detail.

For example, XML permits whitespace to occur at various points within start-tags, and attributes to be specified in any order. Such differences are seldom if ever used to convey meaning, and so these forms are generally considered equivalent:

<p class="a" secure="1">

<p secure = "1" class='a' >

In converting an arbitrary XML document to Canonical XML, attributes are encoded in a normative order (alphabetical by name), and with normative spacing and quoting. Thus, the second form above would be converted to the first.

Canonical XML specifies a number of other details, some of which are:

* the UTF-8 encoding is used
* line-ends are represented using the character 0x0A
* whitespace in attribute values is normalized
* entity references are expanded
* CDATA marked sections are not used
* empty elements are encoded as start/end pairs, not using the special empty-element syntax
* default attributes are made explicit
* superfluous namespace declarations are deleted

Converting a document to Canonical XML is idempotent. That is, the first conversion usually will result in a different string of characters than the original, but repeated conversions will make no further changes.

According to the W3C, if two XML documents have the same canonical form, then the two documents are logically equivalent within the given application context (except for limitations regarding a few unusual cases).

However, in a special context users might care about special semantics beyond the generic logical equivalence with which Canonical XML is associated. For example, a steganography system could conceal information in an XML document by varying whitespace, attribute quoting and order, the use of hexadecimal vs. decimal numeric character references, and so on. Obviously converting such a file to Canonical XML would lose those specialized semantics. On the other hand, XML files that differ in their use of upper- vs. lower-case, or that use archaic versus modern spelling, and so on, might be considered equivalent for certain purposes. Such contexts are beyond the scope of Canonical XML.

ee also

* XML Signature

External links

* [http://www.w3.org/TR/xml-c14n W3C Recommendation, Canonical XML Version 1.0, 15 March 2001]
* [http://www.w3.org/TR/xml-exc-c14n/ W3C Recommendation, Exclusive XML Canonicalization Version 1.0, 18 July 2002]


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • XML Signature — (also called XMLDsig , XML DSig , XML Sig ) is a W3C recommendation that defines an XML syntax for digital signatures. Functionally, it has much in common with PKCS#7 but is more extensible and geared towards signing XML documents. It is used by… …   Wikipedia

  • XML — (англ. eXtensible Markup Language) расширяемый язык разметки Расширение .xml …   Википедия

  • XML-Schema — ist eine Empfehlung des W3C zum Definieren von Strukturen für XML Dokumente. Anders als bei den klassischen XML DTDs wird die Struktur in Form eines XML Dokuments beschrieben. Darüber hinaus wird eine große Anzahl von Datentypen unterstützt.… …   Deutsch Wikipedia

  • XML Schema — XML Schema, abgekürzt XSD, ist eine Empfehlung des W3C zum Definieren von Strukturen für XML Dokumente. Anders als bei den klassischen XML DTDs wird die Struktur in Form eines XML Dokuments beschrieben. Darüber hinaus wird eine große Anzahl von… …   Deutsch Wikipedia

  • XML Schema Definition — XML Schema ist eine Empfehlung des W3C zum Definieren von Strukturen für XML Dokumente. Anders als bei den klassischen XML DTDs wird die Struktur in Form eines XML Dokuments beschrieben. Darüber hinaus wird eine große Anzahl von Datentypen… …   Deutsch Wikipedia

  • XML Base — ist eine vom World Wide Web Consortium empfohlene Möglichkeit, Basis URLs für Teile von XML Dokumenten zu definieren. Basis URL bezeichnet dabei diejenige URL, von der aus relative Pfadangaben im Dokument aufgelöst werden. Die XML Base Empfehlung …   Deutsch Wikipedia

  • XML Events — ist eine Spezifikation des W3C, um Ereignisse, die in einem XML Dokument auftreten, zu handhaben. Diese Ereignisse werden typischerweise durch einen Benutzer ausgelöst, der mit dem Dokument, einer Webseite, mit Hilfe eines Internetbrowsers auf… …   Deutsch Wikipedia

  • XML Schema — XML Schema  язык описания структуры XML документа. Спецификация XML Schema является рекомендацией W3C. Как большинство языков описания XML, XML Schema была задумана для определения правил, которым должен подчиняться документ. Но, в отличие… …   Википедия

  • XML-binary Optimized Packaging — (XOP) ist eine W3C Empfehlung für die Repräsentation binärer Daten in XML Dokumenten. XOP ersetzt damit die sonst für die Repräsentation binärer Daten in XML Dokumenten üblichen Techniken wie Verwendung von CDATA Blöcken, Base64 Kodierung, SOAP… …   Deutsch Wikipedia

  • XML Information Set — (Infoset) ist ein W3C Standard mit dem Status einer Empfehlung. Die Infoset Spezifikation dient als Basis für eine Reihe anderer Spezifikationen, welche Aussagen zum formellen Informationsgehalt von XML Dokumenten zu machen haben. Ein… …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”