diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-04-27 22:46:17 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-04-27 22:46:17 +0100 |
| commit | 6b040ed3f347e34fc89013ff7dc9268c733cee47 (patch) | |
| tree | 252a401c07f61427cbdfd08c9adc9690d879e5b4 /lib/relationships-reader.js | |
| parent | 5610fd885e9255b9569b91b8fc73860d06d74ef4 (diff) | |
Move relationship reading into separate module
Diffstat (limited to 'lib/relationships-reader.js')
| -rw-r--r-- | lib/relationships-reader.js | 25 |
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; +} |
