aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Sanin <aleksey@aleksey.com>2009-07-09 10:26:22 +0200
committerDaniel Veillard <veillard@redhat.com>2009-07-09 10:26:22 +0200
commit838682478cf89ddcbda294d9557c72813135fc7a (patch)
treebeb96f53231fbd3952e611b695e7f2690715e0ad
parent44af232c837312900f7d5c0ad58c2d52cdc8aa8f (diff)
downloadandroid_external_libxml2-838682478cf89ddcbda294d9557c72813135fc7a.tar.gz
android_external_libxml2-838682478cf89ddcbda294d9557c72813135fc7a.tar.bz2
android_external_libxml2-838682478cf89ddcbda294d9557c72813135fc7a.zip
Aleksey Sanin support for c14n 1.1
* c14n.c include/libxml/c14n.h: adds support for C14N 1.1, new flags at the API level * runtest.c Makefile.am testC14N.c xmllint.c: add support in CLI tools and test binaries * result/c14n/1-1-without-comments/* test/c14n/1-1-without-comments/*: add a new batch of tests
-rw-r--r--ChangeLog10
-rw-r--r--Makefile.am2
-rw-r--r--c14n.c411
-rw-r--r--include/libxml/c14n.h19
-rwxr-xr-xresult/c14n/1-1-without-comments/example-14
-rwxr-xr-xresult/c14n/1-1-without-comments/example-211
-rwxr-xr-xresult/c14n/1-1-without-comments/example-314
-rwxr-xr-xresult/c14n/1-1-without-comments/example-49
-rwxr-xr-xresult/c14n/1-1-without-comments/example-53
-rwxr-xr-xresult/c14n/1-1-without-comments/example-61
-rwxr-xr-xresult/c14n/1-1-without-comments/example-71
-rwxr-xr-xresult/c14n/1-1-without-comments/example-81
-rw-r--r--result/c14n/1-1-without-comments/xmlbase-c14n11spec-1021
-rw-r--r--result/c14n/1-1-without-comments/xmlbase-c14n11spec2-1021
-rw-r--r--result/c14n/1-1-without-comments/xmlbase-c14n11spec3-1022
-rw-r--r--result/c14n/1-1-without-comments/xmlbase-prop-114
-rw-r--r--result/c14n/1-1-without-comments/xmlbase-prop-28
-rw-r--r--result/c14n/1-1-without-comments/xmlbase-prop-33
-rw-r--r--result/c14n/1-1-without-comments/xmlbase-prop-41
-rw-r--r--result/c14n/1-1-without-comments/xmlbase-prop-51
-rw-r--r--result/c14n/1-1-without-comments/xmlbase-prop-63
-rw-r--r--result/c14n/1-1-without-comments/xmlbase-prop-77
-rw-r--r--result/c14n/1-1-without-comments/xmlid-prop-18
-rw-r--r--result/c14n/1-1-without-comments/xmlid-prop-25
-rw-r--r--result/c14n/1-1-without-comments/xmllang-prop-18
-rw-r--r--result/c14n/1-1-without-comments/xmllang-prop-23
-rw-r--r--result/c14n/1-1-without-comments/xmllang-prop-33
-rw-r--r--result/c14n/1-1-without-comments/xmllang-prop-45
-rw-r--r--result/c14n/1-1-without-comments/xmlspace-prop-18
-rw-r--r--result/c14n/1-1-without-comments/xmlspace-prop-23
-rw-r--r--result/c14n/1-1-without-comments/xmlspace-prop-33
-rw-r--r--result/c14n/1-1-without-comments/xmlspace-prop-45
-rw-r--r--runtest.c25
-rw-r--r--test/.cvsignore2
-rwxr-xr-xtest/c14n/1-1-without-comments/doc.dtd1
-rwxr-xr-xtest/c14n/1-1-without-comments/example-1.xml14
-rwxr-xr-xtest/c14n/1-1-without-comments/example-2.xml11
-rwxr-xr-xtest/c14n/1-1-without-comments/example-3.xml18
-rwxr-xr-xtest/c14n/1-1-without-comments/example-4.xml9
-rwxr-xr-xtest/c14n/1-1-without-comments/example-5.xml12
-rwxr-xr-xtest/c14n/1-1-without-comments/example-6.xml2
-rwxr-xr-xtest/c14n/1-1-without-comments/example-7.xml11
-rwxr-xr-xtest/c14n/1-1-without-comments/example-7.xpath10
-rwxr-xr-xtest/c14n/1-1-without-comments/example-8.xml11
-rwxr-xr-xtest/c14n/1-1-without-comments/example-8.xpath10
-rwxr-xr-xtest/c14n/1-1-without-comments/world.txt1
-rw-r--r--test/c14n/1-1-without-comments/xmlbase-c14n11spec-102.xml16
-rw-r--r--test/c14n/1-1-without-comments/xmlbase-c14n11spec-102.xpath9
-rw-r--r--test/c14n/1-1-without-comments/xmlbase-c14n11spec2-102.xml16
-rw-r--r--test/c14n/1-1-without-comments/xmlbase-c14n11spec2-102.xpath9
-rw-r--r--test/c14n/1-1-without-comments/xmlbase-c14n11spec3-102.xml14
-rw-r--r--test/c14n/1-1-without-comments/xmlbase-c14n11spec3-102.xpath9
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlbase-prop-1.xml24
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlbase-prop-1.xpath11
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlbase-prop-2.xml23
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlbase-prop-2.xpath10
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlbase-prop-3.xml24
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlbase-prop-3.xpath11
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlbase-prop-4.xml24
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlbase-prop-4.xpath11
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlbase-prop-5.xml24
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlbase-prop-5.xpath11
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlbase-prop-6.xml23
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlbase-prop-6.xpath10
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlbase-prop-7.xml23
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlbase-prop-7.xpath10
-rw-r--r--test/c14n/1-1-without-comments/xmlid-prop-1.xml20
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlid-prop-1.xpath10
-rw-r--r--test/c14n/1-1-without-comments/xmlid-prop-2.xml20
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlid-prop-2.xpath10
-rw-r--r--test/c14n/1-1-without-comments/xmllang-prop-1.xml20
-rwxr-xr-xtest/c14n/1-1-without-comments/xmllang-prop-1.xpath10
-rw-r--r--test/c14n/1-1-without-comments/xmllang-prop-2.xml20
-rwxr-xr-xtest/c14n/1-1-without-comments/xmllang-prop-2.xpath10
-rw-r--r--test/c14n/1-1-without-comments/xmllang-prop-3.xml20
-rwxr-xr-xtest/c14n/1-1-without-comments/xmllang-prop-3.xpath10
-rw-r--r--test/c14n/1-1-without-comments/xmllang-prop-4.xml20
-rwxr-xr-xtest/c14n/1-1-without-comments/xmllang-prop-4.xpath10
-rw-r--r--test/c14n/1-1-without-comments/xmlspace-prop-1.xml20
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlspace-prop-1.xpath10
-rw-r--r--test/c14n/1-1-without-comments/xmlspace-prop-2.xml20
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlspace-prop-2.xpath10
-rw-r--r--test/c14n/1-1-without-comments/xmlspace-prop-3.xml20
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlspace-prop-3.xpath10
-rw-r--r--test/c14n/1-1-without-comments/xmlspace-prop-4.xml20
-rwxr-xr-xtest/c14n/1-1-without-comments/xmlspace-prop-4.xpath10
-rw-r--r--test/c14n/with-comments/doc.dtd1
-rw-r--r--test/c14n/without-comments/doc.dtd1
-rw-r--r--testC14N.c28
-rw-r--r--xmllint.c25
90 files changed, 1296 insertions, 86 deletions
diff --git a/ChangeLog b/ChangeLog
index 9a1666da..790fe5e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Thu Jul 9 10:21:00 CEST 2009 Daniel Veillard <daniel@veillard.com>
+
+ Aleksey Sanin support for c14n 1.1
+ * c14n.c include/libxml/c14n.h: adds support for C14N 1.1,
+ new flags at the API level
+ * runtest.c Makefile.am testC14N.c xmllint.c: add support in CLI
+ tools and test binaries
+ * result/c14n/1-1-without-comments/* test/c14n/1-1-without-comments/*:
+ add a new batch of tests
+
Thu Jul 9 08:52:35 CEST 2009 Daniel Veillard <daniel@veillard.com>
* config.h.in: update of libtool seems to have modified it
diff --git a/Makefile.am b/Makefile.am
index 800a7662..236c26ba 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -923,7 +923,7 @@ VTimingtests: xmllint$(EXEEXT)
C14Ntests : testC14N$(EXEEXT)
@echo "## C14N and XPath regression tests"
- -@(for m in with-comments without-comments exc-without-comments ; do \
+ -@(for m in with-comments without-comments 1-1-without-comments exc-without-comments ; do \
for i in $(srcdir)/test/c14n/$$m/*.xml ; do \
if [ ! -d $$i ] ; then \
name=`basename $$i .xml`; \
diff --git a/c14n.c b/c14n.c
index f3332974..53a19c12 100644
--- a/c14n.c
+++ b/c14n.c
@@ -60,9 +60,11 @@ typedef struct _xmlC14NCtx {
xmlC14NPosition pos;
int parent_is_doc;
xmlC14NVisibleNsStackPtr ns_rendered;
+
+ /* C14N mode */
+ xmlC14NMode mode;
/* exclusive canonicalization */
- int exclusive;
xmlChar **inclusive_ns_prefixes;
/* error number */
@@ -117,6 +119,9 @@ static xmlChar *xmlC11NNormalizeString(const xmlChar * input,
(ctx)->is_visible_callback((ctx)->user_data, \
(xmlNodePtr)(node), (xmlNodePtr)(parent)) : 1)
+#define xmlC14NIsExclusive( ctx ) \
+ ( (ctx)->mode == XML_C14N_EXCLUSIVE_1_0 )
+
/************************************************************************
* *
* Some factorized error routines *
@@ -492,9 +497,7 @@ xmlC14NIsXmlNs(xmlNsPtr ns)
{
return ((ns != NULL) &&
(xmlStrEqual(ns->prefix, BAD_CAST "xml")) &&
- (xmlStrEqual(ns->href,
- BAD_CAST
- "http://www.w3.org/XML/1998/namespace")));
+ (xmlStrEqual(ns->href, XML_XML_NAMESPACE)));
}
@@ -713,7 +716,7 @@ xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
return (-1);
}
- if(!ctx->exclusive) {
+ if(!xmlC14NIsExclusive(ctx)) {
xmlC14NErrParam("processing namespaces axis (exc c14n)");
return (-1);
@@ -845,6 +848,25 @@ xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
/**
+ * xmlC14NIsXmlAttr:
+ * @attr: the attr to check
+ *
+ * Checks whether the given attribute is a default "xml:" namespace
+ * with href="http://www.w3.org/XML/1998/namespace"
+ *
+ * Returns 1 if the node is default or 0 otherwise
+ */
+
+/* todo: make it a define? */
+static int
+xmlC14NIsXmlAttr(xmlAttrPtr attr)
+{
+ return ((attr->ns != NULL) &&
+ (xmlC14NIsXmlNs(attr->ns) != 0));
+}
+
+
+/**
* xmlC14NAttrsCompare:
* @attr1: the pointer tls o first attr
* @attr2: the pointer to second attr
@@ -925,7 +947,7 @@ xmlC14NPrintAttrs(const xmlAttrPtr attr, xmlC14NCtxPtr ctx)
xmlOutputBufferWriteString(ctx->buf, (const char *) attr->name);
xmlOutputBufferWriteString(ctx->buf, "=\"");
- value = xmlNodeListGetString(attr->doc, attr->children, 1);
+ value = xmlNodeListGetString(ctx->doc, attr->children, 1);
/* todo: should we log an error if value==NULL ? */
if (value != NULL) {
buffer = xmlC11NNormalizeAttr(value);
@@ -943,10 +965,133 @@ xmlC14NPrintAttrs(const xmlAttrPtr attr, xmlC14NCtxPtr ctx)
}
/**
+ * xmlC14NFindHiddenParentAttr:
+ *
+ * Finds an attribute in a hidden parent node.
+ *
+ * Returns a pointer to the attribute node (if found) or NULL otherwise.
+ */
+static xmlAttrPtr
+xmlC14NFindHiddenParentAttr(xmlC14NCtxPtr ctx, xmlNodePtr cur, const xmlChar * name, const xmlChar * ns)
+{
+ xmlAttrPtr res;
+ while((cur != NULL) && (!xmlC14NIsVisible(ctx, cur, cur->parent))) {
+ res = xmlHasNsProp(cur, name, ns);
+ if(res != NULL) {
+ return res;
+ }
+
+ cur = cur->parent;
+ }
+
+ return NULL;
+}
+
+/**
+ * xmlC14NFixupBaseAttr:
+ *
+ * Fixes up the xml:base attribute
+ *
+ * Returns the newly created attribute or NULL
+ */
+static xmlAttrPtr
+xmlC14NFixupBaseAttr(xmlC14NCtxPtr ctx, xmlAttrPtr xml_base_attr)
+{
+ xmlChar * res = NULL;
+ xmlNodePtr cur;
+ xmlAttrPtr attr;
+ xmlChar * tmp_str;
+ xmlChar * tmp_str2;
+ int tmp_str_len;
+
+ if ((ctx == NULL) || (xml_base_attr == NULL) || (xml_base_attr->parent == NULL)) {
+ xmlC14NErrParam("processing xml:base attribute");
+ return (NULL);
+ }
+
+ /* start from current value */
+ res = xmlNodeListGetString(ctx->doc, xml_base_attr->children, 1);
+ if(res == NULL) {
+ xmlC14NErrInternal("processing xml:base attribute - can't get attr value");
+ return (NULL);
+ }
+
+ /* go up the stack until we find a node that we rendered already */
+ cur = xml_base_attr->parent->parent;
+ while((cur != NULL) && (!xmlC14NIsVisible(ctx, cur, cur->parent))) {
+ attr = xmlHasNsProp(cur, BAD_CAST "base", XML_XML_NAMESPACE);
+ if(attr != NULL) {
+ /* get attr value */
+ tmp_str = xmlNodeListGetString(ctx->doc, attr->children, 1);
+ if(tmp_str == NULL) {
+ xmlFree(res);
+
+ xmlC14NErrInternal("processing xml:base attribute - can't get attr value");
+ return (NULL);
+ }
+
+ /* we need to add '/' if our current base uri ends with '..' or '.'
+ to ensure that we are forced to go "up" all the time */
+ tmp_str_len = xmlStrlen(tmp_str);
+ if(tmp_str_len > 1 && tmp_str[tmp_str_len - 2] == '.') {
+ tmp_str2 = xmlStrcat(tmp_str, BAD_CAST "/");
+ if(tmp_str2 == NULL) {
+ xmlFree(tmp_str);
+ xmlFree(res);
+
+ xmlC14NErrInternal("processing xml:base attribute - can't modify uri");
+ return (NULL);
+ }
+
+ tmp_str = tmp_str2;
+ }
+
+ /* build uri */
+ tmp_str2 = xmlBuildURI(res, tmp_str);
+ if(tmp_str2 == NULL) {
+ xmlFree(tmp_str);
+ xmlFree(res);
+
+ xmlC14NErrInternal("processing xml:base attribute - can't construct uri");
+ return (NULL);
+ }
+
+ /* cleanup and set the new res */
+ xmlFree(tmp_str);
+ xmlFree(res);
+ res = tmp_str2;
+ }
+
+ /* next */
+ cur = cur->parent;
+ }
+
+ /* check if result uri is empty or not */
+ if((res == NULL) || xmlStrEqual(res, BAD_CAST "")) {
+ xmlFree(res);
+ return (NULL);
+ }
+
+ /* create and return the new attribute node */
+ attr = xmlNewNsProp(NULL, xml_base_attr->ns, BAD_CAST "base", res);
+ if(attr == NULL) {
+ xmlFree(res);
+
+ xmlC14NErrInternal("processing xml:base attribute - can't construct attribute");
+ return (NULL);
+ }
+
+ /* done */
+ xmlFree(res);
+ return (attr);
+}
+
+/**
* xmlC14NProcessAttrsAxis:
* @ctx: the C14N context
* @cur: the current node
* @parent_visible: the visibility of parent node
+ * @all_parents_visible: the visibility of all parent nodes
*
* Prints out canonical attribute axis of the current node to the
* buffer from C14N context as follows
@@ -978,7 +1123,13 @@ static int
xmlC14NProcessAttrsAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int parent_visible)
{
xmlAttrPtr attr;
- xmlListPtr list;
+ xmlListPtr list;
+ xmlAttrPtr attrs_to_delete = NULL;
+
+ /* special processing for 1.1 spec */
+ xmlAttrPtr xml_base_attr = NULL;
+ xmlAttrPtr xml_lang_attr = NULL;
+ xmlAttrPtr xml_space_attr = NULL;
if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
xmlC14NErrParam("processing attributes axis");
@@ -994,42 +1145,184 @@ xmlC14NProcessAttrsAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int parent_visible)
return (-1);
}
- /*
- * Add all visible attributes from current node.
- */
- attr = cur->properties;
- while (attr != NULL) {
- /* check that attribute is visible */
- if (xmlC14NIsVisible(ctx, attr, cur)) {
- xmlListInsert(list, attr);
+ switch(ctx->mode) {
+ case XML_C14N_1_0:
+ /* The processing of an element node E MUST be modified slightly when an XPath node-set is
+ * given as input and the element's parent is omitted from the node-set. The method for processing
+ * the attribute axis of an element E in the node-set is enhanced. All element nodes along E's
+ * ancestor axis are examined for nearest occurrences of attributes in the xml namespace, such
+ * as xml:lang and xml:space (whether or not they are in the node-set). From this list of attributes,
+ * remove any that are in E's attribute axis (whether or not they are in the node-set). Then,
+ * lexicographically merge this attribute list with the nodes of E's attribute axis that are in
+ * the node-set. The result of visiting the attribute axis is computed by processing the attribute
+ * nodes in this merged attribute list.
+ */
+
+ /*
+ * Add all visible attributes from current node.
+ */
+ attr = cur->properties;
+ while (attr != NULL) {
+ /* check that attribute is visible */
+ if (xmlC14NIsVisible(ctx, attr, cur)) {
+ xmlListInsert(list, attr);
+ }
+ attr = attr->next;
}
- attr = attr->next;
- }
- /*
- * include attributes in "xml" namespace defined in ancestors
- * (only for non-exclusive XML Canonicalization)
- */
- if (parent_visible && (!ctx->exclusive) && (cur->parent != NULL)
- && (!xmlC14NIsVisible(ctx, cur->parent, cur->parent->parent))) {
- /*
- * If XPath node-set is not specified then the parent is always
- * visible!
+ /*
+ * Handle xml attributes
*/
- cur = cur->parent;
- while (cur != NULL) {
- attr = cur->properties;
- while (attr != NULL) {
- if ((attr->ns != NULL)
- && (xmlStrEqual(attr->ns->prefix, BAD_CAST "xml"))) {
- if (xmlListSearch(list, attr) == NULL) {
- xmlListInsert(list, attr);
+ if (parent_visible && (cur->parent != NULL) &&
+ (!xmlC14NIsVisible(ctx, cur->parent, cur->parent->parent)))
+ {
+ xmlNodePtr tmp;
+
+ /*
+ * If XPath node-set is not specified then the parent is always
+ * visible!
+ */
+ tmp = cur->parent;
+ while (tmp != NULL) {
+ attr = tmp->properties;
+ while (attr != NULL) {
+ if (xmlC14NIsXmlAttr(attr) != 0) {
+ if (xmlListSearch(list, attr) == NULL) {
+ xmlListInsert(list, attr);
+ }
}
+ attr = attr->next;
+ }
+ tmp = tmp->parent;
+ }
+ }
+
+ /* done */
+ break;
+ case XML_C14N_EXCLUSIVE_1_0:
+ /* attributes in the XML namespace, such as xml:lang and xml:space
+ * are not imported into orphan nodes of the document subset
+ */
+
+ /*
+ * Add all visible attributes from current node.
+ */
+ attr = cur->properties;
+ while (attr != NULL) {
+ /* check that attribute is visible */
+ if (xmlC14NIsVisible(ctx, attr, cur)) {
+ xmlListInsert(list, attr);
+ }
+ attr = attr->next;
+ }
+
+ /* do nothing special for xml attributes */
+ break;
+ case XML_C14N_1_1:
+ /* The processing of an element node E MUST be modified slightly when an XPath node-set is
+ * given as input and some of the element's ancestors are omitted from the node-set.
+ *
+ * Simple inheritable attributes are attributes that have a value that requires at most a simple
+ * redeclaration. This redeclaration is done by supplying a new value in the child axis. The
+ * redeclaration of a simple inheritable attribute A contained in one of E's ancestors is done
+ * by supplying a value to an attribute Ae inside E with the same name. Simple inheritable attributes
+ * are xml:lang and xml:space.
+ *
+ * The method for processing the attribute axis of an element E in the node-set is hence enhanced.
+ * All element nodes along E's ancestor axis are examined for the nearest occurrences of simple
+ * inheritable attributes in the xml namespace, such as xml:lang and xml:space (whether or not they
+ * are in the node-set). From this list of attributes, any simple inheritable attributes that are
+ * already in E's attribute axis (whether or not they are in the node-set) are removed. Then,
+ * lexicographically merge this attribute list with the nodes of E's attribute axis that are in
+ * the node-set. The result of visiting the attribute axis is computed by processing the attribute
+ * nodes in this merged attribute list.
+ *
+ * The xml:id attribute is not a simple inheritable attribute and no processing of these attributes is
+ * performed.
+ *
+ * The xml:base attribute is not a simple inheritable attribute and requires special processing beyond
+ * a simple redeclaration.
+ *
+ * Attributes in the XML namespace other than xml:base, xml:id, xml:lang, and xml:space MUST be processed
+ * as ordinary attributes.
+ */
+
+ /*
+ * Add all visible attributes from current node.
+ */
+ attr = cur->properties;
+ while (attr != NULL) {
+ /* special processing for XML attribute kiks in only when we have invisible parents */
+ if ((!parent_visible) || (xmlC14NIsXmlAttr(attr) == 0)) {
+ /* check that attribute is visible */
+ if (xmlC14NIsVisible(ctx, attr, cur)) {
+ xmlListInsert(list, attr);
+ }
+ } else {
+ int matched = 0;
+
+ /* check for simple inheritance attributes */
+ if((!matched) && (xml_lang_attr == NULL) && xmlStrEqual(attr->name, BAD_CAST "lang")) {
+ xml_lang_attr = attr;
+ matched = 1;
+ }
+ if((!matched) && (xml_space_attr == NULL) && xmlStrEqual(attr->name, BAD_CAST "space")) {
+ xml_space_attr = attr;
+ matched = 1;
+ }
+
+ /* check for base attr */
+ if((!matched) && (xml_base_attr == NULL) && xmlStrEqual(attr->name, BAD_CAST "base")) {
+ xml_base_attr = attr;
+ matched = 1;
+ }
+
+ /* otherwise, it is a normal attribute, so just check if it is visible */
+ if((!matched) && xmlC14NIsVisible(ctx, attr, cur)) {
+ xmlListInsert(list, attr);
}
- attr = attr->next;
}
- cur = cur->parent;
+
+ /* move to the next one */
+ attr = attr->next;
}
+
+ /* special processing for XML attribute kiks in only when we have invisible parents */
+ if ((parent_visible)) {
+
+ /* simple inheritance attributes - copy */
+ if(xml_lang_attr == NULL) {
+ xml_lang_attr = xmlC14NFindHiddenParentAttr(ctx, cur->parent, BAD_CAST "lang", XML_XML_NAMESPACE);
+ }
+ if(xml_lang_attr != NULL) {
+ xmlListInsert(list, xml_lang_attr);
+ }
+ if(xml_space_attr == NULL) {
+ xml_space_attr = xmlC14NFindHiddenParentAttr(ctx, cur->parent, BAD_CAST "space", XML_XML_NAMESPACE);
+ }
+ if(xml_space_attr != NULL) {
+ xmlListInsert(list, xml_space_attr);
+ }
+
+ /* base uri attribute - fix up */
+ if(xml_base_attr == NULL) {
+ /* if we don't have base uri attribute, check if we have a "hidden" one above */
+ xml_base_attr = xmlC14NFindHiddenParentAttr(ctx, cur->parent, BAD_CAST "base", XML_XML_NAMESPACE);
+ }
+ if(xml_base_attr != NULL) {
+ xml_base_attr = xmlC14NFixupBaseAttr(ctx, xml_base_attr);
+ if(xml_base_attr != NULL) {
+ xmlListInsert(list, xml_base_attr);
+
+ /* note that we MUST delete returned attr node ourselves! */
+ xml_base_attr->next = attrs_to_delete;
+ attrs_to_delete = xml_base_attr;
+ }
+ }
+ }
+
+ /* done */
+ break;
}
/*
@@ -1040,6 +1333,7 @@ xmlC14NProcessAttrsAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int parent_visible)
/*
* Cleanup
*/
+ xmlFreePropList(attrs_to_delete);
xmlListDelete(list);
return (0);
}
@@ -1096,6 +1390,8 @@ xmlC14NCheckForRelativeNamespaces(xmlC14NCtxPtr ctx, xmlNodePtr cur)
* xmlC14NProcessElementNode:
* @ctx: the pointer to C14N context object
* @cur: the node to process
+ * @visible: this node is visible
+ * @all_parents_visible: whether all the parents of this node are visible
*
* Canonical XML v 1.0 (http://www.w3.org/TR/xml-c14n)
*
@@ -1159,7 +1455,7 @@ xmlC14NProcessElementNode(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
xmlOutputBufferWriteString(ctx->buf, (const char *) cur->name);
}
- if (!ctx->exclusive) {
+ if (!xmlC14NIsExclusive(ctx)) {
ret = xmlC14NProcessNamespacesAxis(ctx, cur, visible);
} else {
ret = xmlExcC14NProcessNamespacesAxis(ctx, cur, visible);
@@ -1457,9 +1753,10 @@ xmlC14NFreeCtx(xmlC14NCtxPtr ctx)
* or not
* @user_data: the first parameter for @is_visible_callback function
* (in most cases, it is nodes set)
+ * @mode: the c14n mode (see @xmlC14NMode)
* @inclusive_ns_prefixe the list of inclusive namespace prefixes
* ended with a NULL or NULL if there is no
- * inclusive namespaces (only for exclusive
+ * inclusive namespaces (only for `
* canonicalization)
* @with_comments: include comments in the result (!=0) or not (==0)
* @buf: the output buffer to store canonical XML; this
@@ -1473,7 +1770,7 @@ xmlC14NFreeCtx(xmlC14NCtxPtr ctx)
static xmlC14NCtxPtr
xmlC14NNewCtx(xmlDocPtr doc,
xmlC14NIsVisibleCallback is_visible_callback, void* user_data,
- int exclusive, xmlChar ** inclusive_ns_prefixes,
+ xmlC14NMode mode, xmlChar ** inclusive_ns_prefixes,
int with_comments, xmlOutputBufferPtr buf)
{
xmlC14NCtxPtr ctx = NULL;
@@ -1531,11 +1828,11 @@ xmlC14NNewCtx(xmlDocPtr doc,
}
/*
- * Set "exclusive" flag, create a nodes set for namespaces
- * stack and remember list of incluseve prefixes
+ * Set "mode" flag and remember list of incluseve prefixes
+ * for exclusive c14n
*/
- if (exclusive) {
- ctx->exclusive = 1;
+ ctx->mode = mode;
+ if(xmlC14NIsExclusive(ctx)) {
ctx->inclusive_ns_prefixes = inclusive_ns_prefixes;
}
return (ctx);
@@ -1548,8 +1845,7 @@ xmlC14NNewCtx(xmlDocPtr doc,
* or not
* @user_data: the first parameter for @is_visible_callback function
* (in most cases, it is nodes set)
- * @exclusive: the exclusive flag (0 - non-exclusive canonicalization;
- * otherwise - exclusive canonicalization)
+ * @mode: the c14n mode (see @xmlC14NMode)
* @inclusive_ns_prefixes: the list of inclusive namespace prefixes
* ended with a NULL or NULL if there is no
* inclusive namespaces (only for exclusive
@@ -1567,7 +1863,7 @@ xmlC14NNewCtx(xmlDocPtr doc,
*/
int
xmlC14NExecute(xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback,
- void* user_data, int exclusive, xmlChar **inclusive_ns_prefixes,
+ void* user_data, xmlC14NMode mode, xmlChar **inclusive_ns_prefixes,
int with_comments, xmlOutputBufferPtr buf) {
xmlC14NCtxPtr ctx;
@@ -1588,7 +1884,7 @@ xmlC14NExecute(xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback,
}
ctx = xmlC14NNewCtx(doc, is_visible_callback, user_data,
- exclusive, inclusive_ns_prefixes,
+ mode, inclusive_ns_prefixes,
with_comments, buf);
if (ctx == NULL) {
xmlC14NErr(NULL, (xmlNodePtr) doc, XML_C14N_CREATE_CTXT,
@@ -1637,8 +1933,7 @@ xmlC14NExecute(xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback,
* @doc: the XML document for canonization
* @nodes: the nodes set to be included in the canonized image
* or NULL if all document nodes should be included
- * @exclusive: the exclusive flag (0 - non-exclusive canonicalization;
- * otherwise - exclusive canonicalization)
+ * @mode: the c14n mode (see @xmlC14NMode)
* @inclusive_ns_prefixes: the list of inclusive namespace prefixes
* ended with a NULL or NULL if there is no
* inclusive namespaces (only for exclusive
@@ -1656,12 +1951,12 @@ xmlC14NExecute(xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback,
*/
int
xmlC14NDocSaveTo(xmlDocPtr doc, xmlNodeSetPtr nodes,
- int exclusive, xmlChar ** inclusive_ns_prefixes,
+ int mode, xmlChar ** inclusive_ns_prefixes,
int with_comments, xmlOutputBufferPtr buf) {
return(xmlC14NExecute(doc,
(xmlC14NIsVisibleCallback)xmlC14NIsNodeInNodeset,
nodes,
- exclusive,
+ mode,
inclusive_ns_prefixes,
with_comments,
buf));
@@ -1673,8 +1968,7 @@ xmlC14NDocSaveTo(xmlDocPtr doc, xmlNodeSetPtr nodes,
* @doc: the XML document for canonization
* @nodes: the nodes set to be included in the canonized image
* or NULL if all document nodes should be included
- * @exclusive: the exclusive flag (0 - non-exclusive canonicalization;
- * otherwise - exclusive canonicalization)
+ * @mode: the c14n mode (see @xmlC14NMode)
* @inclusive_ns_prefixes: the list of inclusive namespace prefixes
* ended with a NULL or NULL if there is no
* inclusive namespaces (only for exclusive
@@ -1692,7 +1986,7 @@ xmlC14NDocSaveTo(xmlDocPtr doc, xmlNodeSetPtr nodes,
*/
int
xmlC14NDocDumpMemory(xmlDocPtr doc, xmlNodeSetPtr nodes,
- int exclusive, xmlChar ** inclusive_ns_prefixes,
+ xmlC14NMode mode, xmlChar ** inclusive_ns_prefixes,
int with_comments, xmlChar ** doc_txt_ptr)
{
int ret;
@@ -1717,7 +2011,7 @@ xmlC14NDocDumpMemory(xmlDocPtr doc, xmlNodeSetPtr nodes,
/*
* canonize document and write to buffer
*/
- ret = xmlC14NDocSaveTo(doc, nodes, exclusive, inclusive_ns_prefixes,
+ ret = xmlC14NDocSaveTo(doc, nodes, mode, inclusive_ns_prefixes,
with_comments, buf);
if (ret < 0) {
xmlC14NErrInternal("saving doc to output buffer");
@@ -1743,8 +2037,7 @@ xmlC14NDocDumpMemory(xmlDocPtr doc, xmlNodeSetPtr nodes,
* @doc: the XML document for canonization
* @nodes: the nodes set to be included in the canonized image
* or NULL if all document nodes should be included
- * @exclusive: the exclusive flag (0 - non-exclusive canonicalization;
- * otherwise - exclusive canonicalization)
+ * @mode: the c14n mode (see @xmlC14NMode)
* @inclusive_ns_prefixes: the list of inclusive namespace prefixes
* ended with a NULL or NULL if there is no
* inclusive namespaces (only for exclusive
@@ -1764,7 +2057,7 @@ xmlC14NDocDumpMemory(xmlDocPtr doc, xmlNodeSetPtr nodes,
*/
int
xmlC14NDocSave(xmlDocPtr doc, xmlNodeSetPtr nodes,
- int exclusive, xmlChar ** inclusive_ns_prefixes,
+ xmlC14NMode mode, xmlChar ** inclusive_ns_prefixes,
int with_comments, const char *filename, int compression)
{
xmlOutputBufferPtr buf;
@@ -1791,7 +2084,7 @@ xmlC14NDocSave(xmlDocPtr doc, xmlNodeSetPtr nodes,
/*
* canonize document and write to buffer
*/
- ret = xmlC14NDocSaveTo(doc, nodes, exclusive, inclusive_ns_prefixes,
+ ret = xmlC14NDocSaveTo(doc, nodes, mode, inclusive_ns_prefixes,
with_comments, buf);
if (ret < 0) {
xmlC14NErrInternal("cannicanize document to buffer");
diff --git a/include/libxml/c14n.h b/include/libxml/c14n.h
index a8aa737e..e99b1442 100644
--- a/include/libxml/c14n.h
+++ b/include/libxml/c14n.h
@@ -52,11 +52,22 @@ extern "C" {
* ...
*/
+/*
+ * xmlC14NMode:
+ *
+ * Predefined values for C14N modes
+ *
+ */
+typedef enum {
+ XML_C14N_1_0 = 0, /* Origianal C14N 1.0 spec */
+ XML_C14N_EXCLUSIVE_1_0 = 1, /* Exclusive C14N 1.0 spec */
+ XML_C14N_1_1 = 2 /* C14N 1.1 spec */
+} xmlC14NMode;
XMLPUBFUN int XMLCALL
xmlC14NDocSaveTo (xmlDocPtr doc,
xmlNodeSetPtr nodes,
- int exclusive,
+ int mode, /* a xmlC14NMode */
xmlChar **inclusive_ns_prefixes,
int with_comments,
xmlOutputBufferPtr buf);
@@ -64,7 +75,7 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN int XMLCALL
xmlC14NDocDumpMemory (xmlDocPtr doc,
xmlNodeSetPtr nodes,
- int exclusive,
+ xmlC14NMode mode,
xmlChar **inclusive_ns_prefixes,
int with_comments,
xmlChar **doc_txt_ptr);
@@ -72,7 +83,7 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN int XMLCALL
xmlC14NDocSave (xmlDocPtr doc,
xmlNodeSetPtr nodes,
- int exclusive,
+ xmlC14NMode mode,
xmlChar **inclusive_ns_prefixes,
int with_comments,
const char* filename,
@@ -100,7 +111,7 @@ XMLPUBFUN int XMLCALL
xmlC14NExecute (xmlDocPtr doc,
xmlC14NIsVisibleCallback is_visible_callback,
void* user_data,
- int exclusive,
+ xmlC14NMode mode,
xmlChar **inclusive_ns_prefixes,
int with_comments,
xmlOutputBufferPtr buf);
diff --git a/result/c14n/1-1-without-comments/example-1 b/result/c14n/1-1-without-comments/example-1
new file mode 100755
index 00000000..af9a9770
--- /dev/null
+++ b/result/c14n/1-1-without-comments/example-1
@@ -0,0 +1,4 @@
+<?xml-stylesheet href="doc.xsl"
+ type="text/xsl" ?>
+<doc>Hello, world!</doc>
+<?pi-without-data?> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/example-2 b/result/c14n/1-1-without-comments/example-2
new file mode 100755
index 00000000..2afa15cc
--- /dev/null
+++ b/result/c14n/1-1-without-comments/example-2
@@ -0,0 +1,11 @@
+<doc>
+ <clean> </clean>
+ <dirty> A B </dirty>
+ <mixed>
+ A
+ <clean> </clean>
+ B
+ <dirty> A B </dirty>
+ C
+ </mixed>
+</doc> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/example-3 b/result/c14n/1-1-without-comments/example-3
new file mode 100755
index 00000000..4c287e6e
--- /dev/null
+++ b/result/c14n/1-1-without-comments/example-3
@@ -0,0 +1,14 @@
+<doc>
+ <e1></e1>
+ <e2></e2>
+ <e3 id="elem3" name="elem3"></e3>
+ <e4 id="elem4" name="elem4"></e4>
+ <e5 xmlns="http://www.uvic.ca" xmlns:a="http://www.w3.org" xmlns:b="http://www.ietf.org" attr="I'm" attr2="all" b:attr="sorted" a:attr="out"></e5>
+ <e6 xmlns:a="http://www.w3.org">
+ <e7 xmlns="http://www.ietf.org">
+ <e8 xmlns="">
+ <e9 xmlns:a="http://www.ietf.org" attr="default"></e9>
+ </e8>
+ </e7>
+ </e6>
+</doc> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/example-4 b/result/c14n/1-1-without-comments/example-4
new file mode 100755
index 00000000..19a25592
--- /dev/null
+++ b/result/c14n/1-1-without-comments/example-4
@@ -0,0 +1,9 @@
+<doc>
+ <text>First line&#xD;
+Second line</text>
+ <value>2</value>
+ <compute>value&gt;"0" &amp;&amp; value&lt;"10" ?"valid":"error"</compute>
+ <compute expr="value>&quot;0&quot; &amp;&amp; value&lt;&quot;10&quot; ?&quot;valid&quot;:&quot;error&quot;">valid</compute>
+ <norm attr=" ' &#xD;&#xA;&#x9; ' "></norm>
+ <normId id="' &#xD;&#xA;&#x9; '"></normId>
+</doc> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/example-5 b/result/c14n/1-1-without-comments/example-5
new file mode 100755
index 00000000..c232e740
--- /dev/null
+++ b/result/c14n/1-1-without-comments/example-5
@@ -0,0 +1,3 @@
+<doc attrExtEnt="entExt">
+ Hello, world!
+</doc> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/example-6 b/result/c14n/1-1-without-comments/example-6
new file mode 100755
index 00000000..0be38f98
--- /dev/null
+++ b/result/c14n/1-1-without-comments/example-6
@@ -0,0 +1 @@
+<doc>©</doc> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/example-7 b/result/c14n/1-1-without-comments/example-7
new file mode 100755
index 00000000..0a96cc4d
--- /dev/null
+++ b/result/c14n/1-1-without-comments/example-7
@@ -0,0 +1 @@
+<e1 xmlns="http://www.ietf.org" xmlns:w3c="http://www.w3.org"><e3 xmlns="" id="E3" xml:space="preserve"></e3></e1> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/example-8 b/result/c14n/1-1-without-comments/example-8
new file mode 100755
index 00000000..eb830e81
--- /dev/null
+++ b/result/c14n/1-1-without-comments/example-8
@@ -0,0 +1 @@
+<e1 xmlns="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="something/else"><e3 xmlns="" id="E3" xml:base="bar/foo" xml:space="preserve"></e3></e1> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlbase-c14n11spec-102 b/result/c14n/1-1-without-comments/xmlbase-c14n11spec-102
new file mode 100644
index 00000000..421d60bf
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlbase-c14n11spec-102
@@ -0,0 +1 @@
+<e1 xmlns="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://www.example.com/something/else"><e3 xmlns="" id="E3" xml:base="../bar/foo" xml:space="preserve"></e3></e1> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlbase-c14n11spec2-102 b/result/c14n/1-1-without-comments/xmlbase-c14n11spec2-102
new file mode 100644
index 00000000..eb830e81
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlbase-c14n11spec2-102
@@ -0,0 +1 @@
+<e1 xmlns="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="something/else"><e3 xmlns="" id="E3" xml:base="bar/foo" xml:space="preserve"></e3></e1> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlbase-c14n11spec3-102 b/result/c14n/1-1-without-comments/xmlbase-c14n11spec3-102
new file mode 100644
index 00000000..77ef8481
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlbase-c14n11spec3-102
@@ -0,0 +1,2 @@
+<a xml:base="foo/bar"><d xml:base="../../x">
+ </d></a> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlbase-prop-1 b/result/c14n/1-1-without-comments/xmlbase-prop-1
new file mode 100644
index 00000000..da3a2b66
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlbase-prop-1
@@ -0,0 +1,14 @@
+<ietf:c14n11XmlBaseDoc1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://xmlbase.example.org/xmlbase0/">
+ <ietf:e1 xml:base="/xmlbase1/">
+ <ietf:e11 xml:base="/xmlbase11/">
+ <ietf:e111 xml:base="/xmlbase111/"></ietf:e111>
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 xml:base="/xmlbase121/"></ietf:e121>
+ </ietf:e12>
+ </ietf:e1>
+
+ <ietf:e3>
+ <ietf:e31 at="3"></ietf:e31>
+ </ietf:e3>
+</ietf:c14n11XmlBaseDoc1> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlbase-prop-2 b/result/c14n/1-1-without-comments/xmlbase-prop-2
new file mode 100644
index 00000000..aefa8110
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlbase-prop-2
@@ -0,0 +1,8 @@
+<ietf:e1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://xmlbase.example.org/xmlbase1/">
+ <ietf:e11 xml:base="/xmlbase11/">
+ <ietf:e111 xml:base="/xmlbase111/"></ietf:e111>
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 xml:base="/xmlbase121/"></ietf:e121>
+ </ietf:e12>
+ </ietf:e1> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlbase-prop-3 b/result/c14n/1-1-without-comments/xmlbase-prop-3
new file mode 100644
index 00000000..0757d281
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlbase-prop-3
@@ -0,0 +1,3 @@
+<ietf:e11 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://xmlbase.example.org/xmlbase11/">
+ <ietf:e111 xml:base="/xmlbase111/"></ietf:e111>
+ </ietf:e11> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlbase-prop-4 b/result/c14n/1-1-without-comments/xmlbase-prop-4
new file mode 100644
index 00000000..0d45839d
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlbase-prop-4
@@ -0,0 +1 @@
+<ietf:e111 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://xmlbase.example.org/xmlbase111/"></ietf:e111> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlbase-prop-5 b/result/c14n/1-1-without-comments/xmlbase-prop-5
new file mode 100644
index 00000000..95e51d9f
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlbase-prop-5
@@ -0,0 +1 @@
+<ietf:e21 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://xmlbase.example.org/xmlbase21/"></ietf:e21> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlbase-prop-6 b/result/c14n/1-1-without-comments/xmlbase-prop-6
new file mode 100644
index 00000000..a7b61e30
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlbase-prop-6
@@ -0,0 +1,3 @@
+<ietf:e3 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://xmlbase.example.org/xmlbase0/">
+ <ietf:e31 at="3"></ietf:e31>
+ </ietf:e3> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlbase-prop-7 b/result/c14n/1-1-without-comments/xmlbase-prop-7
new file mode 100644
index 00000000..eda3165c
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlbase-prop-7
@@ -0,0 +1,7 @@
+<ietf:c14n11XmlBaseDoc1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://xmlbase.example.org/xmlbase0/">
+
+
+ <ietf:e3>
+ <ietf:e31 at="3"></ietf:e31>
+ </ietf:e3>
+</ietf:c14n11XmlBaseDoc1> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlid-prop-1 b/result/c14n/1-1-without-comments/xmlid-prop-1
new file mode 100644
index 00000000..2a76c06a
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlid-prop-1
@@ -0,0 +1,8 @@
+<ietf:e1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:id="IdInterop">
+ <ietf:e11>
+ <ietf:e111></ietf:e111>
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121></ietf:e121>
+ </ietf:e12>
+ </ietf:e1> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlid-prop-2 b/result/c14n/1-1-without-comments/xmlid-prop-2
new file mode 100644
index 00000000..1dccb8dc
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlid-prop-2
@@ -0,0 +1,5 @@
+<ietf:e11 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
+ <ietf:e111></ietf:e111>
+ </ietf:e11><ietf:e12 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" at="2">
+ <ietf:e121></ietf:e121>
+ </ietf:e12> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmllang-prop-1 b/result/c14n/1-1-without-comments/xmllang-prop-1
new file mode 100644
index 00000000..2581a9d9
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmllang-prop-1
@@ -0,0 +1,8 @@
+<ietf:e1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:lang="EN">
+ <ietf:e11>
+ <ietf:e111></ietf:e111>
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121></ietf:e121>
+ </ietf:e12>
+ </ietf:e1> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmllang-prop-2 b/result/c14n/1-1-without-comments/xmllang-prop-2
new file mode 100644
index 00000000..5add5fab
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmllang-prop-2
@@ -0,0 +1,3 @@
+<ietf:e2 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
+ <ietf:e21></ietf:e21>
+ </ietf:e2> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmllang-prop-3 b/result/c14n/1-1-without-comments/xmllang-prop-3
new file mode 100644
index 00000000..e327ebd9
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmllang-prop-3
@@ -0,0 +1,3 @@
+<ietf:e11 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:lang="EN">
+ <ietf:e111></ietf:e111>
+ </ietf:e11> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmllang-prop-4 b/result/c14n/1-1-without-comments/xmllang-prop-4
new file mode 100644
index 00000000..dc192c92
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmllang-prop-4
@@ -0,0 +1,5 @@
+<ietf:e11 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:lang="EN">
+ <ietf:e111></ietf:e111>
+ </ietf:e11><ietf:e12 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" at="2" xml:lang="EN">
+ <ietf:e121></ietf:e121>
+ </ietf:e12> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlspace-prop-1 b/result/c14n/1-1-without-comments/xmlspace-prop-1
new file mode 100644
index 00000000..7c13accd
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlspace-prop-1
@@ -0,0 +1,8 @@
+<ietf:e1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:space="true">
+ <ietf:e11>
+ <ietf:e111></ietf:e111>
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121></ietf:e121>
+ </ietf:e12>
+ </ietf:e1> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlspace-prop-2 b/result/c14n/1-1-without-comments/xmlspace-prop-2
new file mode 100644
index 00000000..5add5fab
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlspace-prop-2
@@ -0,0 +1,3 @@
+<ietf:e2 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
+ <ietf:e21></ietf:e21>
+ </ietf:e2> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlspace-prop-3 b/result/c14n/1-1-without-comments/xmlspace-prop-3
new file mode 100644
index 00000000..94a1a562
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlspace-prop-3
@@ -0,0 +1,3 @@
+<ietf:e11 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:space="true">
+ <ietf:e111></ietf:e111>
+ </ietf:e11> \ No newline at end of file
diff --git a/result/c14n/1-1-without-comments/xmlspace-prop-4 b/result/c14n/1-1-without-comments/xmlspace-prop-4
new file mode 100644
index 00000000..acbddd4d
--- /dev/null
+++ b/result/c14n/1-1-without-comments/xmlspace-prop-4
@@ -0,0 +1,5 @@
+<ietf:e11 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:space="true">
+ <ietf:e111></ietf:e111>
+ </ietf:e11><ietf:e12 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" at="2" xml:space="true">
+ <ietf:e121></ietf:e121>
+ </ietf:e12> \ No newline at end of file
diff --git a/runtest.c b/runtest.c
index c7d11fa7..c9899535 100644
--- a/runtest.c
+++ b/runtest.c
@@ -3671,7 +3671,7 @@ parse_list(xmlChar *str) {
}
static int
-c14nRunTest(const char* xml_filename, int with_comments, int exclusive,
+c14nRunTest(const char* xml_filename, int with_comments, int mode,
const char* xpath_filename, const char *ns_filename,
const char* result_file) {
xmlDocPtr doc;
@@ -3733,12 +3733,13 @@ c14nRunTest(const char* xml_filename, int with_comments, int exclusive,
/* fprintf(stderr,"File \"%s\" loaded: start canonization\n", xml_filename); */
ret = xmlC14NDocDumpMemory(doc,
(xpath) ? xpath->nodesetval : NULL,
- exclusive, inclusive_namespaces,
+ mode, inclusive_namespaces,
with_comments, &result);
if (ret >= 0) {
if(result != NULL) {
if (compareFileMem(result_file, (const char *) result, ret)) {
fprintf(stderr, "Result mismatch for %s\n", xml_filename);
+ fprintf(stderr, "RESULT:\n%s\n", (const char*)result);
ret = -1;
}
}
@@ -3760,7 +3761,7 @@ c14nRunTest(const char* xml_filename, int with_comments, int exclusive,
}
static int
-c14nCommonTest(const char *filename, int with_comments, int exclusive,
+c14nCommonTest(const char *filename, int with_comments, int mode,
const char *subdir) {
char buf[500];
char prefix[500];
@@ -3793,7 +3794,7 @@ c14nCommonTest(const char *filename, int with_comments, int exclusive,
}
nb_tests++;
- if (c14nRunTest(filename, with_comments, exclusive,
+ if (c14nRunTest(filename, with_comments, mode,
xpath, ns, result) < 0)
ret = 1;
@@ -3808,21 +3809,28 @@ c14nWithCommentTest(const char *filename,
const char *resul ATTRIBUTE_UNUSED,
const char *err ATTRIBUTE_UNUSED,
int options ATTRIBUTE_UNUSED) {
- return(c14nCommonTest(filename, 1, 0, "with-comments"));
+ return(c14nCommonTest(filename, 1, XML_C14N_1_0, "with-comments"));
}
static int
c14nWithoutCommentTest(const char *filename,
const char *resul ATTRIBUTE_UNUSED,
const char *err ATTRIBUTE_UNUSED,
int options ATTRIBUTE_UNUSED) {
- return(c14nCommonTest(filename, 0, 0, "without-comments"));
+ return(c14nCommonTest(filename, 0, XML_C14N_1_0, "without-comments"));
}
static int
c14nExcWithoutCommentTest(const char *filename,
const char *resul ATTRIBUTE_UNUSED,
const char *err ATTRIBUTE_UNUSED,
int options ATTRIBUTE_UNUSED) {
- return(c14nCommonTest(filename, 0, 1, "exc-without-comments"));
+ return(c14nCommonTest(filename, 0, XML_C14N_EXCLUSIVE_1_0, "exc-without-comments"));
+}
+static int
+c14n11WithoutCommentTest(const char *filename,
+ const char *resul ATTRIBUTE_UNUSED,
+ const char *err ATTRIBUTE_UNUSED,
+ int options ATTRIBUTE_UNUSED) {
+ return(c14nCommonTest(filename, 0, XML_C14N_1_1, "1-1-without-comments"));
}
#endif
#if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) && defined (LIBXML_SAX1_ENABLED)
@@ -4257,6 +4265,9 @@ testDesc testDescriptions[] = {
{ "C14N exclusive without comments regression tests" ,
c14nExcWithoutCommentTest, "./test/c14n/exc-without-comments/*.xml", NULL, NULL, NULL,
0 },
+ { "C14N 1.1 without comments regression tests" ,
+ c14n11WithoutCommentTest, "./test/c14n/1-1-without-comments/*.xml", NULL, NULL, NULL,
+ 0 },
#endif
#if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) && defined(LIBXML_SAX1_ENABLED)
{ "Catalog and Threads regression tests" ,
diff --git a/test/.cvsignore b/test/.cvsignore
deleted file mode 100644
index c038ed78..00000000
--- a/test/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/doc.dtd b/test/c14n/1-1-without-comments/doc.dtd
new file mode 100755
index 00000000..c4602397
--- /dev/null
+++ b/test/c14n/1-1-without-comments/doc.dtd
@@ -0,0 +1 @@
+<!-- Empty DTD --> \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/example-1.xml b/test/c14n/1-1-without-comments/example-1.xml
new file mode 100755
index 00000000..ed450c73
--- /dev/null
+++ b/test/c14n/1-1-without-comments/example-1.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+
+<?xml-stylesheet href="doc.xsl"
+ type="text/xsl" ?>
+
+<!DOCTYPE doc SYSTEM "doc.dtd">
+
+<doc>Hello, world!<!-- Comment 1 --></doc>
+
+<?pi-without-data ?>
+
+<!-- Comment 2 -->
+
+<!-- Comment 3 -->
diff --git a/test/c14n/1-1-without-comments/example-2.xml b/test/c14n/1-1-without-comments/example-2.xml
new file mode 100755
index 00000000..74eeea14
--- /dev/null
+++ b/test/c14n/1-1-without-comments/example-2.xml
@@ -0,0 +1,11 @@
+<doc>
+ <clean> </clean>
+ <dirty> A B </dirty>
+ <mixed>
+ A
+ <clean> </clean>
+ B
+ <dirty> A B </dirty>
+ C
+ </mixed>
+</doc>
diff --git a/test/c14n/1-1-without-comments/example-3.xml b/test/c14n/1-1-without-comments/example-3.xml
new file mode 100755
index 00000000..a7a1950a
--- /dev/null
+++ b/test/c14n/1-1-without-comments/example-3.xml
@@ -0,0 +1,18 @@
+<!DOCTYPE doc [<!ATTLIST e9 attr CDATA "default">]>
+<doc>
+ <e1 />
+ <e2 ></e2>
+ <e3 name = "elem3" id="elem3" />
+ <e4 name="elem4" id="elem4" ></e4>
+ <e5 a:attr="out" b:attr="sorted" attr2="all" attr="I'm"
+ xmlns:b="http://www.ietf.org"
+ xmlns:a="http://www.w3.org"
+ xmlns="http://www.uvic.ca"/>
+ <e6 xmlns="" xmlns:a="http://www.w3.org">
+ <e7 xmlns="http://www.ietf.org">
+ <e8 xmlns="" xmlns:a="http://www.w3.org">
+ <e9 xmlns="" xmlns:a="http://www.ietf.org"/>
+ </e8>
+ </e7>
+ </e6>
+</doc>
diff --git a/test/c14n/1-1-without-comments/example-4.xml b/test/c14n/1-1-without-comments/example-4.xml
new file mode 100755
index 00000000..3fba1385
--- /dev/null
+++ b/test/c14n/1-1-without-comments/example-4.xml
@@ -0,0 +1,9 @@
+<!DOCTYPE doc [<!ATTLIST normId id ID #IMPLIED>]>
+<doc>
+ <text>First line&#x0d;&#10;Second line</text>
+ <value>&#x32;</value>
+ <compute><![CDATA[value>"0" && value<"10" ?"valid":"error"]]></compute>
+ <compute expr='value>"0" &amp;&amp; value&lt;"10" ?"valid":"error"'>valid</compute>
+ <norm attr=' &apos; &#x20;&#13;&#xa;&#9; &apos; '/>
+ <normId id=' &apos; &#x20;&#13;&#xa;&#9; &apos; '/>
+</doc>
diff --git a/test/c14n/1-1-without-comments/example-5.xml b/test/c14n/1-1-without-comments/example-5.xml
new file mode 100755
index 00000000..92c5322f
--- /dev/null
+++ b/test/c14n/1-1-without-comments/example-5.xml
@@ -0,0 +1,12 @@
+<!DOCTYPE doc [
+<!ATTLIST doc attrExtEnt ENTITY #IMPLIED>
+<!ENTITY ent1 "Hello">
+<!ENTITY ent2 SYSTEM "world.txt">
+<!ENTITY entExt SYSTEM "earth.gif" NDATA gif>
+<!NOTATION gif SYSTEM "viewgif.exe">
+]>
+<doc attrExtEnt="entExt">
+ &ent1;, &ent2;!
+</doc>
+
+<!-- Let world.txt contain "world" (excluding the quotes) -->
diff --git a/test/c14n/1-1-without-comments/example-6.xml b/test/c14n/1-1-without-comments/example-6.xml
new file mode 100755
index 00000000..31e20718
--- /dev/null
+++ b/test/c14n/1-1-without-comments/example-6.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<doc>&#169;</doc>
diff --git a/test/c14n/1-1-without-comments/example-7.xml b/test/c14n/1-1-without-comments/example-7.xml
new file mode 100755
index 00000000..41171cb4
--- /dev/null
+++ b/test/c14n/1-1-without-comments/example-7.xml
@@ -0,0 +1,11 @@
+<!DOCTYPE doc [
+<!ATTLIST e2 xml:space (default|preserve) 'preserve'>
+<!ATTLIST e3 id ID #IMPLIED>
+]>
+<doc xmlns="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
+ <e1>
+ <e2 xmlns="">
+ <e3 id="E3"/>
+ </e2>
+ </e1>
+</doc>
diff --git a/test/c14n/1-1-without-comments/example-7.xpath b/test/c14n/1-1-without-comments/example-7.xpath
new file mode 100755
index 00000000..84ddb081
--- /dev/null
+++ b/test/c14n/1-1-without-comments/example-7.xpath
@@ -0,0 +1,10 @@
+<XPath xmlns:ietf="http://www.ietf.org" >
+ (//.|//@*|//namespace::*)
+ [
+ self::ietf:e1
+ or
+ (parent::ietf:e1 and not(self::text() or self::e2))
+ or
+ count(id("E3")|ancestor-or-self::node()) = count(ancestor-or-self::node())
+ ]
+</XPath> \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/example-8.xml b/test/c14n/1-1-without-comments/example-8.xml
new file mode 100755
index 00000000..a07f6c7b
--- /dev/null
+++ b/test/c14n/1-1-without-comments/example-8.xml
@@ -0,0 +1,11 @@
+<!DOCTYPE doc [
+<!ATTLIST e2 xml:space (default|preserve) 'preserve'>
+<!ATTLIST e3 id ID #IMPLIED>
+]>
+<doc xmlns="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="something/else">
+ <e1>
+ <e2 xmlns="" xml:id="abc" xml:base="bar/">
+ <e3 id="E3" xml:base="foo"/>
+ </e2>
+ </e1>
+</doc>
diff --git a/test/c14n/1-1-without-comments/example-8.xpath b/test/c14n/1-1-without-comments/example-8.xpath
new file mode 100755
index 00000000..84ddb081
--- /dev/null
+++ b/test/c14n/1-1-without-comments/example-8.xpath
@@ -0,0 +1,10 @@
+<XPath xmlns:ietf="http://www.ietf.org" >
+ (//.|//@*|//namespace::*)
+ [
+ self::ietf:e1
+ or
+ (parent::ietf:e1 and not(self::text() or self::e2))
+ or
+ count(id("E3")|ancestor-or-self::node()) = count(ancestor-or-self::node())
+ ]
+</XPath> \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/world.txt b/test/c14n/1-1-without-comments/world.txt
new file mode 100755
index 00000000..04fea064
--- /dev/null
+++ b/test/c14n/1-1-without-comments/world.txt
@@ -0,0 +1 @@
+world \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/xmlbase-c14n11spec-102.xml b/test/c14n/1-1-without-comments/xmlbase-c14n11spec-102.xml
new file mode 100644
index 00000000..18b7c756
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-c14n11spec-102.xml
@@ -0,0 +1,16 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-c14n11spec-102
+
+Check that correct xml:base fixup is performed.
+-->
+<!DOCTYPE doc [
+ <!ATTLIST e2 xml:space (default|preserve) 'preserve'>
+ <!ATTLIST e3 id ID #IMPLIED>
+]>
+<doc xmlns="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://www.example.com/something/else">
+ <e1>
+ <e2 xmlns="" xml:id="abc" xml:base="../bar/">
+ <e3 id="E3" xml:base="foo"/>
+ </e2>
+ </e1>
+</doc> \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/xmlbase-c14n11spec-102.xpath b/test/c14n/1-1-without-comments/xmlbase-c14n11spec-102.xpath
new file mode 100644
index 00000000..e919acce
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-c14n11spec-102.xpath
@@ -0,0 +1,9 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-c14n11spec-102
+
+Check that correct xml:base fixup is performed.
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[self::ietf:e1 or (parent::ietf:e1 and not(self::text() or self::e2)) or count(id("E3")|ancestor-or-self::node()) = count(ancestor-or-self::node())]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmlbase-c14n11spec2-102.xml b/test/c14n/1-1-without-comments/xmlbase-c14n11spec2-102.xml
new file mode 100644
index 00000000..d271afd1
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-c14n11spec2-102.xml
@@ -0,0 +1,16 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-c14n11spec2-102
+
+Check that correct xml:base fixup is performed.
+-->
+<!DOCTYPE doc [
+ <!ATTLIST e2 xml:space (default|preserve) 'preserve'>
+ <!ATTLIST e3 id ID #IMPLIED>
+]>
+<doc xmlns="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="something/else">
+ <e1>
+ <e2 xmlns="" xml:id="abc" xml:base="bar/">
+ <e3 id="E3" xml:base="foo"/>
+ </e2>
+ </e1>
+</doc> \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/xmlbase-c14n11spec2-102.xpath b/test/c14n/1-1-without-comments/xmlbase-c14n11spec2-102.xpath
new file mode 100644
index 00000000..cdaad3ef
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-c14n11spec2-102.xpath
@@ -0,0 +1,9 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-c14n11spec2-102
+
+Check that correct xml:base fixup is performed.
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[self::ietf:e1 or (parent::ietf:e1 and not(self::text() or self::e2)) or count(id("E3")|ancestor-or-self::node()) = count(ancestor-or-self::node())]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmlbase-c14n11spec3-102.xml b/test/c14n/1-1-without-comments/xmlbase-c14n11spec3-102.xml
new file mode 100644
index 00000000..f46e1e9e
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-c14n11spec3-102.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-c14n11spec3-102
+
+Check that correct xml:base fixup is performed.
+-->
+<a xml:base="foo/bar">
+ <b xml:base="..">
+ <c xml:base="..">
+ <d xml:base="x">
+ </d>
+ </c>
+ </b>
+</a>
diff --git a/test/c14n/1-1-without-comments/xmlbase-c14n11spec3-102.xpath b/test/c14n/1-1-without-comments/xmlbase-c14n11spec3-102.xpath
new file mode 100644
index 00000000..1d8dd713
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-c14n11spec3-102.xpath
@@ -0,0 +1,9 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-c14n11spec2-102
+
+Check that correct xml:base fixup is performed.
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[self::a or ancestor-or-self::d]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmlbase-prop-1.xml b/test/c14n/1-1-without-comments/xmlbase-prop-1.xml
new file mode 100755
index 00000000..24a899b7
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-prop-1.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-prop-1
+
+Check that implementations of [XML-C14N1.1] work properly when the
+xml:base origin appears in the output document subset and also children
+with xml:base, which do not require further processing, are also present.
+-->
+<ietf:c14n11XmlBaseDoc1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://xmlbase.example.org/xmlbase0/">
+ <ietf:e1 xml:base="/xmlbase1/">
+ <ietf:e11 xml:base="/xmlbase11/">
+ <ietf:e111 xml:base="/xmlbase111/"/>
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 xml:base="/xmlbase121/"/>
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2>
+ <ietf:e21 xml:base="/xmlbase21/"/>
+ </ietf:e2>
+ <ietf:e3>
+ <ietf:e31 at="3"/>
+ </ietf:e3>
+</ietf:c14n11XmlBaseDoc1>
diff --git a/test/c14n/1-1-without-comments/xmlbase-prop-1.xpath b/test/c14n/1-1-without-comments/xmlbase-prop-1.xpath
new file mode 100755
index 00000000..168e98d6
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-prop-1.xpath
@@ -0,0 +1,11 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-prop-1
+
+Check that implementations of [XML-C14N1.1] work properly when the
+xml:base origin appears in the output document subset and also children
+with xml:base, which do not require further processing, are also present.
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:c14n11XmlBaseDoc1 and not(ancestor-or-self::ietf:e2)]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmlbase-prop-2.xml b/test/c14n/1-1-without-comments/xmlbase-prop-2.xml
new file mode 100755
index 00000000..4c85329b
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-prop-2.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-prop-2
+
+Check that implementations of [XML-C14N1.1] properly build the xml:base
+at the first level (ietf:e1).
+-->
+<ietf:c14n11XmlBaseDoc1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://xmlbase.example.org/xmlbase0/">
+ <ietf:e1 xml:base="/xmlbase1/">
+ <ietf:e11 xml:base="/xmlbase11/">
+ <ietf:e111 xml:base="/xmlbase111/"/>
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 xml:base="/xmlbase121/"/>
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2>
+ <ietf:e21 xml:base="/xmlbase21/"/>
+ </ietf:e2>
+ <ietf:e3>
+ <ietf:e31 at="3"/>
+ </ietf:e3>
+</ietf:c14n11XmlBaseDoc1>
diff --git a/test/c14n/1-1-without-comments/xmlbase-prop-2.xpath b/test/c14n/1-1-without-comments/xmlbase-prop-2.xpath
new file mode 100755
index 00000000..fdab0856
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-prop-2.xpath
@@ -0,0 +1,10 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-prop-2
+
+Check that implementations of [XML-C14N1.1] properly build the xml:base
+at the first level (ietf:e1).
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:e1]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmlbase-prop-3.xml b/test/c14n/1-1-without-comments/xmlbase-prop-3.xml
new file mode 100755
index 00000000..19ce7387
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-prop-3.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-prop-3
+
+Check that implementations of [XML-C14N1.1] properly build the xml:base
+if one of intermediate the levels (ietf:e1) are absent from the document
+subset.
+-->
+<ietf:c14n11XmlBaseDoc1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://xmlbase.example.org/xmlbase0/">
+ <ietf:e1 xml:base="/xmlbase1/">
+ <ietf:e11 xml:base="/xmlbase11/">
+ <ietf:e111 xml:base="/xmlbase111/"/>
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 xml:base="/xmlbase121/"/>
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2>
+ <ietf:e21 xml:base="/xmlbase21/"/>
+ </ietf:e2>
+ <ietf:e3>
+ <ietf:e31 at="3"/>
+ </ietf:e3>
+</ietf:c14n11XmlBaseDoc1>
diff --git a/test/c14n/1-1-without-comments/xmlbase-prop-3.xpath b/test/c14n/1-1-without-comments/xmlbase-prop-3.xpath
new file mode 100755
index 00000000..de875083
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-prop-3.xpath
@@ -0,0 +1,11 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-prop-3
+
+Check that implementations of [XML-C14N1.1] properly build the xml:base
+if one of intermediate the levels (ietf:e1) are absent from the document
+subset.
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:e11]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmlbase-prop-4.xml b/test/c14n/1-1-without-comments/xmlbase-prop-4.xml
new file mode 100755
index 00000000..57e4436f
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-prop-4.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-prop-4
+
+Check that implementations of [XML-C14N1.1] properly build the xml:base
+if several intermediate levels (ietf:e1 and ietf:e11) are absent from
+the document subset.
+-->
+<ietf:c14n11XmlBaseDoc1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://xmlbase.example.org/xmlbase0/">
+ <ietf:e1 xml:base="/xmlbase1/">
+ <ietf:e11 xml:base="/xmlbase11/">
+ <ietf:e111 xml:base="/xmlbase111/"/>
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 xml:base="/xmlbase121/"/>
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2>
+ <ietf:e21 xml:base="/xmlbase21/"/>
+ </ietf:e2>
+ <ietf:e3>
+ <ietf:e31 at="3"/>
+ </ietf:e3>
+</ietf:c14n11XmlBaseDoc1>
diff --git a/test/c14n/1-1-without-comments/xmlbase-prop-4.xpath b/test/c14n/1-1-without-comments/xmlbase-prop-4.xpath
new file mode 100755
index 00000000..818ef109
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-prop-4.xpath
@@ -0,0 +1,11 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-prop-4
+
+Check that implementations of [XML-C14N1.1] properly build the xml:base
+if several intermediate levels (ietf:e1 and ietf:e11) are absent from
+the document subset.
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:e111]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmlbase-prop-5.xml b/test/c14n/1-1-without-comments/xmlbase-prop-5.xml
new file mode 100755
index 00000000..f92a897b
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-prop-5.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-prop-5
+
+Check that implementations of [XML-C14N1.1] properly build the xml:base
+if one intermediate level (ietf:e2) without any xml:base attribute is absent
+from the document subset.
+-->
+<ietf:c14n11XmlBaseDoc1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://xmlbase.example.org/xmlbase0/">
+ <ietf:e1 xml:base="/xmlbase1/">
+ <ietf:e11 xml:base="/xmlbase11/">
+ <ietf:e111 xml:base="/xmlbase111/"/>
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 xml:base="/xmlbase121/"/>
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2>
+ <ietf:e21 xml:base="/xmlbase21/"/>
+ </ietf:e2>
+ <ietf:e3>
+ <ietf:e31 at="3"/>
+ </ietf:e3>
+</ietf:c14n11XmlBaseDoc1>
diff --git a/test/c14n/1-1-without-comments/xmlbase-prop-5.xpath b/test/c14n/1-1-without-comments/xmlbase-prop-5.xpath
new file mode 100755
index 00000000..7020803f
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-prop-5.xpath
@@ -0,0 +1,11 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-prop-5
+
+Check that implementations of [XML-C14N1.1] properly build the xml:base
+if one intermediate level (ietf:e2) without any xml:base attribute is absent
+from the document subset.
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:e21]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmlbase-prop-6.xml b/test/c14n/1-1-without-comments/xmlbase-prop-6.xml
new file mode 100755
index 00000000..62824f91
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-prop-6.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-prop-6
+
+Check that implementations of [XML-C14N1.1] properly build the xml:base in
+one element that originally had no xml:base attribute.
+-->
+<ietf:c14n11XmlBaseDoc1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://xmlbase.example.org/xmlbase0/">
+ <ietf:e1 xml:base="/xmlbase1/">
+ <ietf:e11 xml:base="/xmlbase11/">
+ <ietf:e111 xml:base="/xmlbase111/"/>
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 xml:base="/xmlbase121/"/>
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2>
+ <ietf:e21 xml:base="/xmlbase21/"/>
+ </ietf:e2>
+ <ietf:e3>
+ <ietf:e31 at="3"/>
+ </ietf:e3>
+</ietf:c14n11XmlBaseDoc1>
diff --git a/test/c14n/1-1-without-comments/xmlbase-prop-6.xpath b/test/c14n/1-1-without-comments/xmlbase-prop-6.xpath
new file mode 100755
index 00000000..2b93c646
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-prop-6.xpath
@@ -0,0 +1,10 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-prop-6
+
+Check that implementations of [XML-C14N1.1] properly build the xml:base in
+one element that originally had no xml:base attribute.
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:e3]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmlbase-prop-7.xml b/test/c14n/1-1-without-comments/xmlbase-prop-7.xml
new file mode 100755
index 00000000..ee139167
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-prop-7.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-prop-7
+
+Check that implementations of [XML-C14N1.1] do not pass the xml:base
+to another element when it is not necessary.
+-->
+<ietf:c14n11XmlBaseDoc1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="http://xmlbase.example.org/xmlbase0/">
+ <ietf:e1 xml:base="/xmlbase1/">
+ <ietf:e11 xml:base="/xmlbase11/">
+ <ietf:e111 xml:base="/xmlbase111/"/>
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 xml:base="/xmlbase121/"/>
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2>
+ <ietf:e21 xml:base="/xmlbase21/"/>
+ </ietf:e2>
+ <ietf:e3>
+ <ietf:e31 at="3"/>
+ </ietf:e3>
+</ietf:c14n11XmlBaseDoc1>
diff --git a/test/c14n/1-1-without-comments/xmlbase-prop-7.xpath b/test/c14n/1-1-without-comments/xmlbase-prop-7.xpath
new file mode 100755
index 00000000..7d37ab83
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlbase-prop-7.xpath
@@ -0,0 +1,10 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#c14n11xmlbase-prop-7
+
+Check that implementations of [XML-C14N1.1] do not pass the xml:base
+to another element when it is not necessary.
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:c14n11XmlBaseDoc1 and not(ancestor-or-self::ietf:e1 or ancestor-or-self::ietf:e2)]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmlid-prop-1.xml b/test/c14n/1-1-without-comments/xmlid-prop-1.xml
new file mode 100644
index 00000000..ca58c2b0
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlid-prop-1.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLID
+
+Check that implementations of [XML-C14N1.1] handle xml:id attributes
+as defined in [XML-C14N1.1]
+-->
+<ietf:c14n11XmlIdDoc1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
+ <ietf:e1 xml:id="IdInterop">
+ <ietf:e11>
+ <ietf:e111 />
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 />
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2 >
+ <ietf:e21 />
+ </ietf:e2>
+</ietf:c14n11XmlIdDoc1> \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/xmlid-prop-1.xpath b/test/c14n/1-1-without-comments/xmlid-prop-1.xpath
new file mode 100755
index 00000000..dc5573c0
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlid-prop-1.xpath
@@ -0,0 +1,10 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLID
+
+Check that implementations of [XML-C14N1.1] handle xml:id attributes
+as defined in [XML-C14N1.1]
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:e1]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmlid-prop-2.xml b/test/c14n/1-1-without-comments/xmlid-prop-2.xml
new file mode 100644
index 00000000..ca58c2b0
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlid-prop-2.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLID
+
+Check that implementations of [XML-C14N1.1] handle xml:id attributes
+as defined in [XML-C14N1.1]
+-->
+<ietf:c14n11XmlIdDoc1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
+ <ietf:e1 xml:id="IdInterop">
+ <ietf:e11>
+ <ietf:e111 />
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 />
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2 >
+ <ietf:e21 />
+ </ietf:e2>
+</ietf:c14n11XmlIdDoc1> \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/xmlid-prop-2.xpath b/test/c14n/1-1-without-comments/xmlid-prop-2.xpath
new file mode 100755
index 00000000..bed44b7f
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlid-prop-2.xpath
@@ -0,0 +1,10 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLID
+
+Check that implementations of [XML-C14N1.1] handle xml:id attributes
+as defined in [XML-C14N1.1]
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:e11 or ancestor-or-self::ietf:e12]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmllang-prop-1.xml b/test/c14n/1-1-without-comments/xmllang-prop-1.xml
new file mode 100644
index 00000000..1111e33b
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmllang-prop-1.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLLANG
+
+Check that implementations of [XML-C14N1.1] handle xml:lang attributes
+as defined in [XML-C14N1.1]
+-->
+<ietf:c14n11Xmllang xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
+ <ietf:e1 xml:lang="EN">
+ <ietf:e11>
+ <ietf:e111 />
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 />
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2 >
+ <ietf:e21 />
+ </ietf:e2>
+</ietf:c14n11Xmllang> \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/xmllang-prop-1.xpath b/test/c14n/1-1-without-comments/xmllang-prop-1.xpath
new file mode 100755
index 00000000..224924ef
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmllang-prop-1.xpath
@@ -0,0 +1,10 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLLANG
+
+Check that implementations of [XML-C14N1.1] handle xml:lang attributes
+as defined in [XML-C14N1.1]
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:e1]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmllang-prop-2.xml b/test/c14n/1-1-without-comments/xmllang-prop-2.xml
new file mode 100644
index 00000000..1111e33b
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmllang-prop-2.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLLANG
+
+Check that implementations of [XML-C14N1.1] handle xml:lang attributes
+as defined in [XML-C14N1.1]
+-->
+<ietf:c14n11Xmllang xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
+ <ietf:e1 xml:lang="EN">
+ <ietf:e11>
+ <ietf:e111 />
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 />
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2 >
+ <ietf:e21 />
+ </ietf:e2>
+</ietf:c14n11Xmllang> \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/xmllang-prop-2.xpath b/test/c14n/1-1-without-comments/xmllang-prop-2.xpath
new file mode 100755
index 00000000..ca217581
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmllang-prop-2.xpath
@@ -0,0 +1,10 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLLANG
+
+Check that implementations of [XML-C14N1.1] handle xml:lang attributes
+as defined in [XML-C14N1.1]
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:e2]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmllang-prop-3.xml b/test/c14n/1-1-without-comments/xmllang-prop-3.xml
new file mode 100644
index 00000000..1111e33b
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmllang-prop-3.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLLANG
+
+Check that implementations of [XML-C14N1.1] handle xml:lang attributes
+as defined in [XML-C14N1.1]
+-->
+<ietf:c14n11Xmllang xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
+ <ietf:e1 xml:lang="EN">
+ <ietf:e11>
+ <ietf:e111 />
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 />
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2 >
+ <ietf:e21 />
+ </ietf:e2>
+</ietf:c14n11Xmllang> \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/xmllang-prop-3.xpath b/test/c14n/1-1-without-comments/xmllang-prop-3.xpath
new file mode 100755
index 00000000..86e77fa6
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmllang-prop-3.xpath
@@ -0,0 +1,10 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLLANG
+
+Check that implementations of [XML-C14N1.1] handle xml:lang attributes
+as defined in [XML-C14N1.1]
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:e11]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmllang-prop-4.xml b/test/c14n/1-1-without-comments/xmllang-prop-4.xml
new file mode 100644
index 00000000..1111e33b
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmllang-prop-4.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLLANG
+
+Check that implementations of [XML-C14N1.1] handle xml:lang attributes
+as defined in [XML-C14N1.1]
+-->
+<ietf:c14n11Xmllang xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
+ <ietf:e1 xml:lang="EN">
+ <ietf:e11>
+ <ietf:e111 />
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 />
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2 >
+ <ietf:e21 />
+ </ietf:e2>
+</ietf:c14n11Xmllang> \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/xmllang-prop-4.xpath b/test/c14n/1-1-without-comments/xmllang-prop-4.xpath
new file mode 100755
index 00000000..fdc7661e
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmllang-prop-4.xpath
@@ -0,0 +1,10 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLLANG
+
+Check that implementations of [XML-C14N1.1] handle xml:lang attributes
+as defined in [XML-C14N1.1]
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:e11 or ancestor-or-self::ietf:e12]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmlspace-prop-1.xml b/test/c14n/1-1-without-comments/xmlspace-prop-1.xml
new file mode 100644
index 00000000..62da9e4c
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlspace-prop-1.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLSPACE
+
+Check that implementations of [XML-C14N1.1] handle xml:space attributes
+as defined in [XML-C14N1.1]
+-->
+<ietf:c14n11XmlSpaceDoc1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
+ <ietf:e1 xml:space="true">
+ <ietf:e11>
+ <ietf:e111 />
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 />
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2 >
+ <ietf:e21 />
+ </ietf:e2>
+</ietf:c14n11XmlSpaceDoc1> \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/xmlspace-prop-1.xpath b/test/c14n/1-1-without-comments/xmlspace-prop-1.xpath
new file mode 100755
index 00000000..bad373a4
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlspace-prop-1.xpath
@@ -0,0 +1,10 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLSPACE
+
+Check that implementations of [XML-C14N1.1] handle xml:space attributes
+as defined in [XML-C14N1.1]
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:e1]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmlspace-prop-2.xml b/test/c14n/1-1-without-comments/xmlspace-prop-2.xml
new file mode 100644
index 00000000..62da9e4c
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlspace-prop-2.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLSPACE
+
+Check that implementations of [XML-C14N1.1] handle xml:space attributes
+as defined in [XML-C14N1.1]
+-->
+<ietf:c14n11XmlSpaceDoc1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
+ <ietf:e1 xml:space="true">
+ <ietf:e11>
+ <ietf:e111 />
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 />
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2 >
+ <ietf:e21 />
+ </ietf:e2>
+</ietf:c14n11XmlSpaceDoc1> \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/xmlspace-prop-2.xpath b/test/c14n/1-1-without-comments/xmlspace-prop-2.xpath
new file mode 100755
index 00000000..ffb7d854
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlspace-prop-2.xpath
@@ -0,0 +1,10 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLSPACE
+
+Check that implementations of [XML-C14N1.1] handle xml:space attributes
+as defined in [XML-C14N1.1]
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:e2]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmlspace-prop-3.xml b/test/c14n/1-1-without-comments/xmlspace-prop-3.xml
new file mode 100644
index 00000000..62da9e4c
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlspace-prop-3.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLSPACE
+
+Check that implementations of [XML-C14N1.1] handle xml:space attributes
+as defined in [XML-C14N1.1]
+-->
+<ietf:c14n11XmlSpaceDoc1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
+ <ietf:e1 xml:space="true">
+ <ietf:e11>
+ <ietf:e111 />
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 />
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2 >
+ <ietf:e21 />
+ </ietf:e2>
+</ietf:c14n11XmlSpaceDoc1> \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/xmlspace-prop-3.xpath b/test/c14n/1-1-without-comments/xmlspace-prop-3.xpath
new file mode 100755
index 00000000..3f27aed4
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlspace-prop-3.xpath
@@ -0,0 +1,10 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLSPACE
+
+Check that implementations of [XML-C14N1.1] handle xml:space attributes
+as defined in [XML-C14N1.1]
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:e11]
+</XPath>
diff --git a/test/c14n/1-1-without-comments/xmlspace-prop-4.xml b/test/c14n/1-1-without-comments/xmlspace-prop-4.xml
new file mode 100644
index 00000000..62da9e4c
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlspace-prop-4.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLSPACE
+
+Check that implementations of [XML-C14N1.1] handle xml:space attributes
+as defined in [XML-C14N1.1]
+-->
+<ietf:c14n11XmlSpaceDoc1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org">
+ <ietf:e1 xml:space="true">
+ <ietf:e11>
+ <ietf:e111 />
+ </ietf:e11>
+ <ietf:e12 at="2">
+ <ietf:e121 />
+ </ietf:e12>
+ </ietf:e1>
+ <ietf:e2 >
+ <ietf:e21 />
+ </ietf:e2>
+</ietf:c14n11XmlSpaceDoc1> \ No newline at end of file
diff --git a/test/c14n/1-1-without-comments/xmlspace-prop-4.xpath b/test/c14n/1-1-without-comments/xmlspace-prop-4.xpath
new file mode 100755
index 00000000..49c43952
--- /dev/null
+++ b/test/c14n/1-1-without-comments/xmlspace-prop-4.xpath
@@ -0,0 +1,10 @@
+<!--
+http://www.w3.org/TR/xmldsig2ed-tests/#XMLSPACE
+
+Check that implementations of [XML-C14N1.1] handle xml:space attributes
+as defined in [XML-C14N1.1]
+-->
+<XPath xmlns:ietf="http://www.ietf.org" >
+(//. | //@* | //namespace::*)
+[ancestor-or-self::ietf:e11 or ancestor-or-self::ietf:e12]
+</XPath>
diff --git a/test/c14n/with-comments/doc.dtd b/test/c14n/with-comments/doc.dtd
index e69de29b..c4602397 100644
--- a/test/c14n/with-comments/doc.dtd
+++ b/test/c14n/with-comments/doc.dtd
@@ -0,0 +1 @@
+<!-- Empty DTD --> \ No newline at end of file
diff --git a/test/c14n/without-comments/doc.dtd b/test/c14n/without-comments/doc.dtd
index e69de29b..c4602397 100644
--- a/test/c14n/without-comments/doc.dtd
+++ b/test/c14n/without-comments/doc.dtd
@@ -0,0 +1 @@
+<!-- Empty DTD --> \ No newline at end of file
diff --git a/testC14N.c b/testC14N.c
index 674fc71e..ba70127e 100644
--- a/testC14N.c
+++ b/testC14N.c
@@ -32,13 +32,17 @@ static void usage(const char *name) {
name);
fprintf(stderr, "where <mode> is one of following:\n");
fprintf(stderr,
- "--with-comments \t XML file canonization w comments\n");
+ "--with-comments \t XML file canonicalization v1.0 w comments \n");
fprintf(stderr,
- "--without-comments \t XML file canonization w/o comments\n");
+ "--without-comments \t XML file canonicalization v1.0 w/o comments\n");
fprintf(stderr,
- "--exc-with-comments \t Exclusive XML file canonization w comments\n");
+ "--1-1-with-comments \t XML file canonicalization v1.1 w comments\n");
fprintf(stderr,
- "--exc-without-comments\t Exclusive XML file canonization w/o comments\n");
+ "--1-1-without-comments \t XML file canonicalization v1.1 w/o comments\n");
+ fprintf(stderr,
+ "--exc-with-comments \t Exclusive XML file canonicalization v1.0 w comments\n");
+ fprintf(stderr,
+ "--exc-without-comments\t Exclusive XML file canonicalization v1.0 w/o comments\n");
}
static xmlXPathObjectPtr
@@ -49,7 +53,7 @@ static xmlChar **parse_list(xmlChar *str);
/* static void print_xpath_nodes(xmlNodeSetPtr nodes); */
static int
-test_c14n(const char* xml_filename, int with_comments, int exclusive,
+test_c14n(const char* xml_filename, int with_comments, int mode,
const char* xpath_filename, xmlChar **inclusive_namespaces) {
xmlDocPtr doc;
xmlXPathObjectPtr xpath = NULL;
@@ -96,7 +100,7 @@ test_c14n(const char* xml_filename, int with_comments, int exclusive,
/* fprintf(stderr,"File \"%s\" loaded: start canonization\n", xml_filename); */
ret = xmlC14NDocDumpMemory(doc,
(xpath) ? xpath->nodesetval : NULL,
- exclusive, inclusive_namespaces,
+ mode, inclusive_namespaces,
with_comments, &result);
if(ret >= 0) {
if(result != NULL) {
@@ -135,22 +139,26 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error: wrong number of arguments.\n");
usage(argv[0]);
} else if(strcmp(argv[1], "--with-comments") == 0) {
- ret = test_c14n(argv[2], 1, 0, (argc > 3) ? argv[3] : NULL, NULL);
+ ret = test_c14n(argv[2], 1, XML_C14N_1_0, (argc > 3) ? argv[3] : NULL, NULL);
} else if(strcmp(argv[1], "--without-comments") == 0) {
- ret = test_c14n(argv[2], 0, 0, (argc > 3) ? argv[3] : NULL, NULL);
+ ret = test_c14n(argv[2], 0, XML_C14N_1_0, (argc > 3) ? argv[3] : NULL, NULL);
+ } else if(strcmp(argv[1], "--1-1-with-comments") == 0) {
+ ret = test_c14n(argv[2], 1, XML_C14N_1_1, (argc > 3) ? argv[3] : NULL, NULL);
+ } else if(strcmp(argv[1], "--1-1-without-comments") == 0) {
+ ret = test_c14n(argv[2], 0, XML_C14N_1_1, (argc > 3) ? argv[3] : NULL, NULL);
} else if(strcmp(argv[1], "--exc-with-comments") == 0) {
xmlChar **list;
/* load exclusive namespace from command line */
list = (argc > 4) ? parse_list((xmlChar *)argv[4]) : NULL;
- ret = test_c14n(argv[2], 1, 1, (argc > 3) ? argv[3] : NULL, list);
+ ret = test_c14n(argv[2], 1, XML_C14N_EXCLUSIVE_1_0, (argc > 3) ? argv[3] : NULL, list);
if(list != NULL) xmlFree(list);
} else if(strcmp(argv[1], "--exc-without-comments") == 0) {
xmlChar **list;
/* load exclusive namespace from command line */
list = (argc > 4) ? parse_list((xmlChar *)argv[4]) : NULL;
- ret = test_c14n(argv[2], 0, 1, (argc > 3) ? argv[3] : NULL, list);
+ ret = test_c14n(argv[2], 0, XML_C14N_EXCLUSIVE_1_0, (argc > 3) ? argv[3] : NULL, list);
if(list != NULL) xmlFree(list);
} else {
fprintf(stderr, "Error: bad option.\n");
diff --git a/xmllint.c b/xmllint.c
index 77c1e62f..a668570e 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -184,6 +184,7 @@ static int nocatalogs = 0;
#endif
#ifdef LIBXML_C14N_ENABLED
static int canonical = 0;
+static int canonical_11 = 0;
static int exc_canonical = 0;
#endif
#ifdef LIBXML_READER_ENABLED
@@ -2429,7 +2430,19 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
xmlChar *result = NULL;
int size;
- size = xmlC14NDocDumpMemory(doc, NULL, 0, NULL, 1, &result);
+ size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_0, NULL, 1, &result);
+ if (size >= 0) {
+ write(1, result, size);
+ xmlFree(result);
+ } else {
+ fprintf(stderr, "Failed to canonicalize\n");
+ progresult = XMLLINT_ERR_OUT;
+ }
+ } else if (canonical) {
+ xmlChar *result = NULL;
+ int size;
+
+ size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_1, NULL, 1, &result);
if (size >= 0) {
write(1, result, size);
xmlFree(result);
@@ -2442,7 +2455,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
xmlChar *result = NULL;
int size;
- size = xmlC14NDocDumpMemory(doc, NULL, 1, NULL, 1, &result);
+ size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_EXCLUSIVE_1_0, NULL, 1, &result);
if (size >= 0) {
write(1, result, size);
xmlFree(result);
@@ -2878,7 +2891,8 @@ static void usage(const char *name) {
printf("\t--encode encoding : output in the given encoding\n");
printf("\t--dropdtd : remove the DOCTYPE of the input docs\n");
#endif /* LIBXML_OUTPUT_ENABLED */
- printf("\t--c14n : save in W3C canonical format (with comments)\n");
+ printf("\t--c14n : save in W3C canonical format v1.0 (with comments)\n");
+ printf("\t--c14n11 : save in W3C canonical format v1.1 (with comments)\n");
printf("\t--exc-c14n : save in W3C exclusive canonical format (with comments)\n");
#ifdef LIBXML_C14N_ENABLED
#endif /* LIBXML_C14N_ENABLED */
@@ -3141,6 +3155,11 @@ main(int argc, char **argv) {
canonical++;
options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD;
}
+ else if ((!strcmp(argv[i], "-c14n11")) ||
+ (!strcmp(argv[i], "--c14n11"))) {
+ canonical_11++;
+ options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD;
+ }
else if ((!strcmp(argv[i], "-exc-c14n")) ||
(!strcmp(argv[i], "--exc-c14n"))) {
exc_canonical++;