aboutsummaryrefslogtreecommitdiff
path: root/lib/relationships-reader.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/relationships-reader.js')
-rw-r--r--lib/relationships-reader.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/relationships-reader.js b/lib/relationships-reader.js
new file mode 100644
index 0000000..fe6c7f1
--- /dev/null
+++ b/lib/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;
+}