aboutsummaryrefslogtreecommitdiff
path: root/lib/docx/relationships-reader.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-03-18 14:15:33 +0000
committerMichael Williamson <mike@zwobble.org>2014-03-18 14:15:33 +0000
commit45f302766a3a5ca99338fd8e5fef07dec42c0e56 (patch)
treee5081b43310e6c3698c08ab021e0d61d0a84d09c /lib/docx/relationships-reader.js
parentdca50ccd84f91a7db2a41a59e15b3ed95b2c3f46 (diff)
Move modules for docx reading into separate directory
Diffstat (limited to 'lib/docx/relationships-reader.js')
-rw-r--r--lib/docx/relationships-reader.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/docx/relationships-reader.js b/lib/docx/relationships-reader.js
new file mode 100644
index 0000000..fe6c7f1
--- /dev/null
+++ b/lib/docx/relationships-reader.js
@@ -0,0 +1,25 @@
+var readXmlFromZipFile = require("./office-xml-reader").readXmlFromZipFile;
+
+
+exports.readRelationshipsFromZipFile = readRelationshipsFromZipFile;
+
+
+function readRelationshipsFromZipFile(file) {
+ return readXmlFromZipFile(file, "word/_rels/document.xml.rels")
+ .then(function(relationshipsXml) {
+ return relationshipsXml ? readRelationships(relationshipsXml) : {};
+ });
+}
+
+
+function readRelationships(relationshipsXml) {
+ var relationships = {};
+ relationshipsXml.root.children.forEach(function(child) {
+ if (child.name === "{http://schemas.openxmlformats.org/package/2006/relationships}:Relationship") {
+ relationships[child.attributes.Id] = {
+ target: child.attributes.Target
+ };
+ }
+ });
+ return relationships;
+}