This document outlines test cases for Canonical XML 2.0 [[!XML-C14N20]]. Changes since the previous publication include a correction to the text in (diff).
inNsPushdown.xml
.<CanonicalizationMethod>
element containing
canonicalization parameters.
c14nDefault.xml
: Default canonicalization.c14nComment.xml
: Canonicalization with comment removal.c14nPrefix.xml
: Canonicalization with prefix rewriting.c14nPrefixQName.xml
: Canonicalization with prefix rewriting
and a Qname aware attribute xsi:type
.c14nQname.xml
: Canonicalization with
a Qname aware attribute xsi:type
, but not prefix rewriting.c14nQnameElem.xml
: Canonicalization with a
Qname aware element <a:bar>
, but not prefix rewriting.c14nQnameXpathElem.xml
: Canonicalization with a
Qname aware element <a:bar>
, and Qname aware XPath element
<dsig2:IncludedXPath>
, but not prefix rewriting.c14nPrefixQnameXpathElem.xml
: Canonicalization with
prefix rewriting and a
Qname aware element <a:bar>
, and Qname aware XPath element <dsig2:IncludedXPath>
.out_inNsPushdown_c14nDefault.xml
. <?xml version="1.0"?>
<!DOCTYPE doc SYSTEM "doc.dtd">
Original Data | After c14n | After c14n with Comments |
---|---|---|
Note: For "After c14n", the input document and canonical form are identical. Both end with '>' character.
"After c14n with Trim whitespace" Demonstrates:A
and B
but remove
all leading and trailing whitespace Original Data | After c14n | After c14n with Trim whitespace |
---|---|---|
<e1 />
becomes <e1></e1>
<e2 ></e2>
becomes <e2></e2>
<e5>
the namespace declarations precede the attribute declarations.<e9 attr="default">
. Note: Some start tags in the canonical form are very long, but each start tag in this example is entirely on a single line.
Note: In e5
, b:attr
precedes
a:attr
because the primary key is namespace URI not namespace
prefix, and attr2
precedes b:attr
because
the default namespace is not applied to unqualified attributes (so
the namespace URI for attr2
is empty).
Original Data | After c14n | After c14n with PrefixRewrite |
---|---|---|
After c14n with Trim whitespace | ||
Note: The last element, normId
, is well-formed
but violates a validity constraint for attributes of type ID. For
testing canonical XML implementations based on validating processors,
remove the line containing this element from the input and canonical
form. In general, XML consumers should be discouraged from using this
feature of XML.
Note: Whitespace character references other than   are not affected by attribute value normalization [[!XML10]].
Note: In the canonical form,
the value of the attribute named attr
in the element
norm
begins with a space, an apostrophe (single quote), then
four spaces before the first character reference.
Note: The expr
attribute of the second
compute
element contains no line breaks.
Original Data | After c14n | After c14n with Trim whitespace |
---|---|---|
Original Data | After c14n | After c14n with Trim whitespace |
---|---|---|
Note: The content of the doc element are two octets whose hexadecimal values are C2 and A9, which is the UTF-8 encoding of the UCS codepoint for the copyright sign (©).
Original Data | After c14n |
---|---|
Original Data | After c14n | After c14n with PrefixRewrite |
---|---|---|
Original Data | After c14n | After c14n with PrefixRewrite |
---|---|---|
In this example there are four prefixes declarations: "a", "b", "c" and "d". They map to namespace URIs "http://z3", "http://z2", "http://z1" and "http://z0" respectively.
Notice the following things in the default canonicalization ("After c14n"):
Original Data | After c14n | After c14n with PrefixRewrite |
---|---|---|
In this example there are three prefixes "a", "b" and the default prefix. The "foo" element defines them to be "http://z3", "http://z2" and "" respectively. But the "bar" redeclares these prefixes to "http://z2", "http://z3" abd "http://z0" respectively.
Notice the following things in the default canonicalization ("After c14n"):
And notice these things in canonicalization with prefix rewriting ("After c14n with PrefixRewrite"):
Original Data | After c14n | After c14n with PrefixRewrite |
---|---|---|
In this example there are five prefixes "a", "b", "c", "d" and the default prefix and they are all declared to the same namespace URI "http://z0". The "a" prefix is defined twice, one in the "foo" element, and then again in "c:bar" element; obviously the definition of "a" in "c:bar" is unnecessary.
Notice the following things in the default canonicalization ("After c14n"):
Original Data | After c14n | After c14n with PrefixRewrite |
---|---|---|
In this example there are are three special namespace declaration the "xml" namespace used
in the attribute xml:id="23"
and also the "xsi" and "xsd" namespaces used in
xsi:type="xsd:string"
.
Canonicalization only treats "xml" as a special namespace. It is never rewritten by prefix-rewriting. "xsi" and "xsd" are treated as regular namespaces.
Notice the following things in the default canonicalization ("After c14n"):
CanonicalzationMethod
in c14nQname.xml.
it lists "xsi:type" as a Qualified Attribute in the QNameAware element. CanonicalzationMethod
in c14nPrefixQname.xml.
it lists "xsi:type" as a Qualified Attribute in the QNameAware element. It also PrefixRewite=sequential xsi:type="xsd:string"
changes
to n2:type="n1:string".
Original Data | After c14n | After c14n with PrefixRewrite |
---|---|---|
After c14n with QNameAware | After c14n with QNameAware and PrefixRewrite | |
Notice the following things in the default canonicalization ("After c14n"):
Notice the following things in the default canonicalization ("After c14n with QNameAware <a:bar>"):
Notice the following things in the default canonicalization ("After c14n with QNameAware <a:bar> and <dsig2:IncludedXPath>"):
Notice the following things in the default canonicalization ("After c14n with QNameAware <a:bar> and <dsig2:IncludedXPath> and PrefixRewrite"):
Original Data | After c14n | After c14n with QNameAware <a:bar> |
---|---|---|
After c14n with QNameAware <a:bar> and <dsig2:IncludedXPath> | After c14n with QNameAware <a:bar> and <dsig2:IncludedXPath> and PrefixRewrite | |