diff --git a/lib/c14n-canonicalization.js b/lib/c14n-canonicalization.js index ac533481..9d0419b4 100644 --- a/lib/c14n-canonicalization.js +++ b/lib/c14n-canonicalization.js @@ -208,7 +208,12 @@ C14nCanonicalization.prototype.process = function(node, options) { var defaultNsForPrefix = options.defaultNsForPrefix || {}; var ancestorNamespaces = options.ancestorNamespaces || []; - var res = this.processInner(node, [], defaultNs, defaultNsForPrefix, ancestorNamespaces); + var prefixesInScope = []; + for (var i = 0; i < ancestorNamespaces.length; i++) { + prefixesInScope.push(ancestorNamespaces[i].prefix); + } + + var res = this.processInner(node, prefixesInScope, defaultNs, defaultNsForPrefix, ancestorNamespaces); return res; }; diff --git a/test/c14n-non-exclusive-unit-test.js b/test/c14n-non-exclusive-unit-test.js index 49c837b8..e4a45e22 100644 --- a/test/c14n-non-exclusive-unit-test.js +++ b/test/c14n-non-exclusive-unit-test.js @@ -176,3 +176,11 @@ exports["C14n: Don't redeclare an attribute's namespace prefix if already in sco test_C14nCanonicalization(test, xml, xpath, expected); } + +exports["C14n: Don't declare an attribute's namespace prefix if in scope from parent"] = function(test) { + var xml = "" + var xpath = "/root/child1"; + var expected = ''; + + test_C14nCanonicalization(test, xml, xpath, expected); +}