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/office-xml-reader.js | |
| parent | dca50ccd84f91a7db2a41a59e15b3ed95b2c3f46 (diff) | |
Move modules for docx reading into separate directory
Diffstat (limited to 'lib/docx/office-xml-reader.js')
| -rw-r--r-- | lib/docx/office-xml-reader.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/docx/office-xml-reader.js b/lib/docx/office-xml-reader.js new file mode 100644 index 0000000..39b700e --- /dev/null +++ b/lib/docx/office-xml-reader.js @@ -0,0 +1,29 @@ +var promises = require("../promises"); +var xmlreader = require("../xmlreader"); + + +exports.readXmlFromZipFile = readXmlFromZipFile; + +var xmlNamespaceMap = { + "http://schemas.openxmlformats.org/wordprocessingml/2006/main": "w", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships": "r", + "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing": "wp", + "http://schemas.openxmlformats.org/drawingml/2006/main": "a", + "http://schemas.openxmlformats.org/drawingml/2006/picture": "pic", + "http://schemas.openxmlformats.org/package/2006/content-types": "content-types" +}; + + +function read(xmlString) { + return xmlreader.read(xmlString, xmlNamespaceMap); +} + + +function readXmlFromZipFile(docxFile, path) { + if (docxFile.exists(path)) { + return docxFile.read(path, "utf-8") + .then(read); + } else { + return promises.resolve(null); + } +} |
