diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-03-18 14:15:33 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-03-18 14:15:33 +0000 |
| commit | 45f302766a3a5ca99338fd8e5fef07dec42c0e56 (patch) | |
| tree | e5081b43310e6c3698c08ab021e0d61d0a84d09c /lib/docx/relationships-reader.js | |
| parent | dca50ccd84f91a7db2a41a59e15b3ed95b2c3f46 (diff) | |
Move modules for docx reading into separate directory
Diffstat (limited to 'lib/docx/relationships-reader.js')
| -rw-r--r-- | lib/docx/relationships-reader.js | 25 |
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; +} |
