Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

core-xform: Tolerate a missing cp: namespace for the coreProperties element#564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

papandreou
Copy link
Contributor

I ran into a weird spreadsheet that claims it was generated byApache POI. It is missing thecp: namespace for the<cp:coreProperties> element:

<?xml version="1.0" encoding="UTF-8"?><corePropertiesxmlns="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"xmlns:dc="http://purl.org/dc/elements/1.1/"xmlns:dcterms="http://purl.org/dc/terms/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  <dcterms:createdxsi:type="dcterms:W3CDTF">2018-05-08T14:56:50Z</dcterms:created>  <dc:creator>Apache POI</dc:creator></coreProperties>

which makes exceljs die with:

Error: Unexpected xml node in parseClose: coreProperties    at module.exports.parseClose (/Users/andreaslind/work/exceljs/lib/xlsx/xform/core/core-xform.js:126:15)    at SAXStream.<anonymous> (/Users/andreaslind/work/exceljs/lib/xlsx/xform/base-xform.js:87:21)    at SAXStream.emit (events.js:160:13)    at SAXParser.me._parser.(anonymous function) [as onclosetag] (/Users/andreaslind/work/exceljs/node_modules/sax/lib/sax.js:258:17)    at emit (/Users/andreaslind/work/exceljs/node_modules/sax/lib/sax.js:624:35)    at emitNode (/Users/andreaslind/work/exceljs/node_modules/sax/lib/sax.js:629:5)    at closeTag (/Users/andreaslind/work/exceljs/node_modules/sax/lib/sax.js:889:7)    at SAXParser.write (/Users/andreaslind/work/exceljs/node_modules/sax/lib/sax.js:1436:13)    at SAXStream.write (/Users/andreaslind/work/exceljs/node_modules/sax/lib/sax.js:239:18)    at /Users/andreaslind/work/exceljs/lib/utils/stream-buf.js:195:14

The enclosed fix tolerates the missing namespace so the metadata is parsed.

@papandreou
Copy link
ContributorAuthor

Sorry, the error and stack trace isn’t the right one, it was initially complaining inparseOpen.

@papandreou
Copy link
ContributorAuthor

The correct stack trace was:

Error: Unexpected xml node in parseOpen: {"name":"coreProperties","attributes":{"xmlns":"http://schemas.openxmlformats.org/package/2006/metadata/core-properties","xmlns:cp":"http://schemas.openxmlformats.org/package/2006/metadata/core-properties","xmlns:dc":"http://purl.org/dc/elements/1.1/","xmlns:dcterms":"http://purl.org/dc/terms/","xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance"},"isSelfClosing":false}  File "/app/node_modules/exceljs/dist/es5/xlsx/xform/core/core-xform.js", line 89, in module.exports.parseOpen            throw new Error('Unexpected xml node in parseOpen: ' + JSON.stringify(node));  File "/app/node_modules/exceljs/dist/es5/xlsx/xform/base-xform.js", line 69, in SAXStream.<anonymous>              self.parseOpen(node);  File "events.js", line 180, in SAXStream.emit  File "domain.js", line 421, in SAXStream.emit  File "SAXParser.me._parser.(anonymous function) [as onopentag] (/app/node_modules/exceljs/node_modules/sax/lib/sax.js", line 258, in <unknown>  File "/app/node_modules/exceljs/node_modules/sax/lib/sax.js", line 624, in emit        parser[event] && parser[event](data)  File "/app/node_modules/exceljs/node_modules/sax/lib/sax.js", line 629, in emitNode        emit(parser, nodeType, data)  File "/app/node_modules/exceljs/node_modules/sax/lib/sax.js", line 825, in openTag        emitNode(parser, 'onopentag', parser.tag)  File "/app/node_modules/exceljs/node_modules/sax/lib/sax.js", line 1391, in SAXParser.write                openTag(parser)  File "/app/node_modules/exceljs/node_modules/sax/lib/sax.js", line 239, in SAXStream.write        this._parser.write(data.toString())  File "/app/node_modules/exceljs/dist/es5/utils/stream-buf.js", line 196, in <unknown>            pipe.write(chunk.toBuffer(), function () {  File "<anonymous>", line unknown, in new Promise  File "/app/node_modules/promish/lib/promish-class.js", line 23, in new Promish            super(f);  File "/app/node_modules/exceljs/dist/es5/utils/stream-buf.js", line 195, in write          return new PromishLib.Promish(function (resolve) {  File "<anonymous>", line unknown, in Array.map  File "/app/node_modules/exceljs/dist/es5/utils/stream-buf.js", line 201, in module.exports._pipe        var promises = this.pipes.map(write);  File "/app/node_modules/exceljs/dist/es5/utils/stream-buf.js", line 265, in module.exports._flush            this._pipe(this.buffers.shift());  File "/app/node_modules/exceljs/dist/es5/utils/stream-buf.js", line 280, in writeComplete            _this._flush();  File "/app/node_modules/exceljs/dist/es5/utils/stream-buf.js", line 290, in module.exports.end          writeComplete();  File "/app/node_modules/exceljs/dist/es5/utils/stream-buf.js", line 340, in module.exports.pipe          this.end();  File "/app/node_modules/exceljs/dist/es5/xlsx/xform/base-xform.js", line 102, in module.exports.parseStream        stream.pipe(parser);  File "/app/node_modules/exceljs/dist/es5/xlsx/xlsx.js", line 302, in ZipReader.<anonymous>              promise = coreXform.parseStream(entry).then(function (coreProperties) {

@guyonrocheguyonroche merged commit22f464a intoexceljs:masterJun 5, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@papandreou@guyonroche

[8]ページ先頭

©2009-2025 Movatter.jp