diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-08-16 15:59:55 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-08-16 15:59:55 +0100 |
| commit | 4236b58ed1e5448b0ce43b87bf6b5df585db2a32 (patch) | |
| tree | c413fd0f91ad864dd2370f4047137304ce9d9f49 | |
| parent | a2872927a9616ca63387c96e5c7c95b184bb6ebc (diff) | |
Don't include colon when using curly brace syntax for node names
| -rw-r--r-- | lib/docx/relationships-reader.js | 2 | ||||
| -rw-r--r-- | lib/docx/style-map.js | 2 | ||||
| -rw-r--r-- | lib/xml/reader.js | 4 | ||||
| -rw-r--r-- | lib/xml/writer.js | 2 | ||||
| -rw-r--r-- | tests/xml/reader.tests.js | 2 | ||||
| -rw-r--r-- | tests/xml/writer.tests.js | 6 |
6 files changed, 9 insertions, 9 deletions
diff --git a/lib/docx/relationships-reader.js b/lib/docx/relationships-reader.js index 7cae534..7747bda 100644 --- a/lib/docx/relationships-reader.js +++ b/lib/docx/relationships-reader.js @@ -4,7 +4,7 @@ exports.readRelationships = readRelationships; function readRelationships(relationshipsXml) { var relationships = {}; relationshipsXml.root.children.forEach(function(child) { - if (child.name === "{http://schemas.openxmlformats.org/package/2006/relationships}:Relationship") { + if (child.name === "{http://schemas.openxmlformats.org/package/2006/relationships}Relationship") { relationships[child.attributes.Id] = { target: child.attributes.Target }; diff --git a/lib/docx/style-map.js b/lib/docx/style-map.js index bd770bd..76f6903 100644 --- a/lib/docx/style-map.js +++ b/lib/docx/style-map.js @@ -19,7 +19,7 @@ function updateRelationships(docxFile) { return officeXml.readXmlFromZipFile(docxFile, path) .then(function(relationshipsDocument) { var relationships = relationshipsDocument.root; - relationships.children.push(xml.element("{" + relationshipsUri + "}:Relationship", { + relationships.children.push(xml.element("{" + relationshipsUri + "}Relationship", { "Id": "rMammothStyleMap", "Type": "http://schemas.zwobble.org/mammoth/style-map", "Target": "/" + styleMapPath diff --git a/lib/xml/reader.js b/lib/xml/reader.js index 6189851..67b69be 100644 --- a/lib/xml/reader.js +++ b/lib/xml/reader.js @@ -35,11 +35,11 @@ function readString(xmlString, namespaceMap) { var mappedPrefix = namespaceMap[node.uri]; var prefix; if (mappedPrefix) { - prefix = mappedPrefix; + prefix = mappedPrefix + ":"; } else { prefix = "{" + node.uri + "}"; } - return prefix + ":" + node.local; + return prefix + node.local; } else { return node.local; } diff --git a/lib/xml/writer.js b/lib/xml/writer.js index 9bf8c35..0c44982 100644 --- a/lib/xml/writer.js +++ b/lib/xml/writer.js @@ -25,7 +25,7 @@ function writeString(root, namespaces) { } function mapElementName(name) { - var longFormMatch = /^\{(.*)\}:(.*)$/.exec(name); + var longFormMatch = /^\{(.*)\}(.*)$/.exec(name); if (longFormMatch) { var prefix = uriToPrefix[longFormMatch[1]]; return prefix + (prefix === "" ? "" : ":") + longFormMatch[2]; diff --git a/tests/xml/reader.tests.js b/tests/xml/reader.tests.js index 49bcab5..afc98de 100644 --- a/tests/xml/reader.tests.js +++ b/tests/xml/reader.tests.js @@ -40,7 +40,7 @@ describe('xmlreader.readString', function() { test('unmapped namespaces URIs are included in braces as prefix', function() { return xmlreader.readString('<w:body xmlns:w="word"/>').then(function(result) { - assert.deepEqual(result.root.name, "{word}:body"); + assert.deepEqual(result.root.name, "{word}body"); }); }); diff --git a/tests/xml/writer.tests.js b/tests/xml/writer.tests.js index 7f9440f..d41ddc1 100644 --- a/tests/xml/writer.tests.js +++ b/tests/xml/writer.tests.js @@ -45,14 +45,14 @@ describe('xml.writer', function() { }); test('can write root element with long-form prefix when URI is namespace', function() { - var element = xml.element("{music}:root"); + var element = xml.element("{music}root"); assertXmlString(element, {"m": "music"}, '<m:root xmlns:m="music"/>'); }); test('can write child elements with long-form prefix when URI is namespace', function() { var element = xml.element("root", {}, [ - xml.element("{music}:album") + xml.element("{music}album") ]); assertXmlString(element, {"m": "music"}, '<root xmlns:m="music"><m:album/></root>'); @@ -68,7 +68,7 @@ describe('xml.writer', function() { test('default namespace has key of empty string', function() { var element = xml.element("root", {}, [ - xml.element("{music}:album") + xml.element("{music}album") ]); assertXmlString(element, {"": "music"}, '<root xmlns="music"><album/></root>'); |
