1- const XmlStream = require ( ' ../../../utils/xml-stream' ) ;
2- const BaseXform = require ( ' ../base-xform' ) ;
3- const DateXform = require ( ' ../simple/date-xform' ) ;
4- const StringXform = require ( ' ../simple/string-xform' ) ;
5- const IntegerXform = require ( ' ../simple/integer-xform' ) ;
1+ const XmlStream = require ( " ../../../utils/xml-stream" ) ;
2+ const BaseXform = require ( " ../base-xform" ) ;
3+ const DateXform = require ( " ../simple/date-xform" ) ;
4+ const StringXform = require ( " ../simple/string-xform" ) ;
5+ const IntegerXform = require ( " ../simple/integer-xform" ) ;
66
77class CoreXform extends BaseXform {
88 constructor ( ) {
99 super ( ) ;
1010
1111 this . map = {
12- 'dc:creator' : new StringXform ( { tag : 'dc:creator' } ) ,
13- 'dc:title' : new StringXform ( { tag : 'dc:title' } ) ,
14- 'dc:subject' : new StringXform ( { tag : 'dc:subject' } ) ,
15- 'dc:description' : new StringXform ( { tag : 'dc:description' } ) ,
16- 'dc:identifier' : new StringXform ( { tag : 'dc:identifier' } ) ,
17- 'dc:language' : new StringXform ( { tag : 'dc:language' } ) ,
18- 'cp:keywords' : new StringXform ( { tag : 'cp:keywords' } ) ,
19- 'cp:category' : new StringXform ( { tag : 'cp:category' } ) ,
20- 'cp:lastModifiedBy' : new StringXform ( { tag : 'cp:lastModifiedBy' } ) ,
21- 'cp:lastPrinted' : new DateXform ( { tag : 'cp:lastPrinted' , format : CoreXform . DateFormat } ) ,
22- 'cp:revision' : new IntegerXform ( { tag : 'cp:revision' } ) ,
23- 'cp:version' : new StringXform ( { tag : 'cp:version' } ) ,
24- 'cp:contentStatus' : new StringXform ( { tag : 'cp:contentStatus' } ) ,
25- 'cp:contentType' : new StringXform ( { tag : 'cp:contentType' } ) ,
26- 'dcterms:created' : new DateXform ( {
27- tag : 'dcterms:created' ,
12+ "dc:creator" : new StringXform ( { tag : "dc:creator" } ) ,
13+ "dc:title" : new StringXform ( { tag : "dc:title" } ) ,
14+ "dc:subject" : new StringXform ( { tag : "dc:subject" } ) ,
15+ "dc:description" : new StringXform ( { tag : "dc:description" } ) ,
16+ "dc:identifier" : new StringXform ( { tag : "dc:identifier" } ) ,
17+ "dc:language" : new StringXform ( { tag : "dc:language" } ) ,
18+ "cp:keywords" : new StringXform ( { tag : "cp:keywords" } ) ,
19+ "cp:category" : new StringXform ( { tag : "cp:category" } ) ,
20+ "cp:lastModifiedBy" : new StringXform ( { tag : "cp:lastModifiedBy" } ) ,
21+ "cp:lastPrinted" : new DateXform ( {
22+ tag : "cp:lastPrinted" ,
23+ format : CoreXform . DateFormat ,
24+ } ) ,
25+ "cp:revision" : new IntegerXform ( { tag : "cp:revision" } ) ,
26+ "cp:version" : new StringXform ( { tag : "cp:version" } ) ,
27+ "cp:contentStatus" : new StringXform ( { tag : "cp:contentStatus" } ) ,
28+ "cp:contentType" : new StringXform ( { tag : "cp:contentType" } ) ,
29+ "dcterms:created" : new DateXform ( {
30+ tag : "dcterms:created" ,
2831 attrs : CoreXform . DateAttrs ,
2932 format : CoreXform . DateFormat ,
3033 } ) ,
31- ' dcterms:modified' : new DateXform ( {
32- tag : ' dcterms:modified' ,
34+ " dcterms:modified" : new DateXform ( {
35+ tag : " dcterms:modified" ,
3336 attrs : CoreXform . DateAttrs ,
3437 format : CoreXform . DateFormat ,
3538 } ) ,
@@ -39,24 +42,24 @@ class CoreXform extends BaseXform {
3942 render ( xmlStream , model ) {
4043 xmlStream . openXml ( XmlStream . StdDocAttributes ) ;
4144
42- xmlStream . openNode ( ' cp:coreProperties' , CoreXform . CORE_PROPERTY_ATTRIBUTES ) ;
45+ xmlStream . openNode ( " cp:coreProperties" , CoreXform . CORE_PROPERTY_ATTRIBUTES ) ;
4346
44- this . map [ ' dc:creator' ] . render ( xmlStream , model . creator ) ;
45- this . map [ ' dc:title' ] . render ( xmlStream , model . title ) ;
46- this . map [ ' dc:subject' ] . render ( xmlStream , model . subject ) ;
47- this . map [ ' dc:description' ] . render ( xmlStream , model . description ) ;
48- this . map [ ' dc:identifier' ] . render ( xmlStream , model . identifier ) ;
49- this . map [ ' dc:language' ] . render ( xmlStream , model . language ) ;
50- this . map [ ' cp:keywords' ] . render ( xmlStream , model . keywords ) ;
51- this . map [ ' cp:category' ] . render ( xmlStream , model . category ) ;
52- this . map [ ' cp:lastModifiedBy' ] . render ( xmlStream , model . lastModifiedBy ) ;
53- this . map [ ' cp:lastPrinted' ] . render ( xmlStream , model . lastPrinted ) ;
54- this . map [ ' cp:revision' ] . render ( xmlStream , model . revision ) ;
55- this . map [ ' cp:version' ] . render ( xmlStream , model . version ) ;
56- this . map [ ' cp:contentStatus' ] . render ( xmlStream , model . contentStatus ) ;
57- this . map [ ' cp:contentType' ] . render ( xmlStream , model . contentType ) ;
58- this . map [ ' dcterms:created' ] . render ( xmlStream , model . created ) ;
59- this . map [ ' dcterms:modified' ] . render ( xmlStream , model . modified ) ;
47+ this . map [ " dc:creator" ] . render ( xmlStream , model . creator ) ;
48+ this . map [ " dc:title" ] . render ( xmlStream , model . title ) ;
49+ this . map [ " dc:subject" ] . render ( xmlStream , model . subject ) ;
50+ this . map [ " dc:description" ] . render ( xmlStream , model . description ) ;
51+ this . map [ " dc:identifier" ] . render ( xmlStream , model . identifier ) ;
52+ this . map [ " dc:language" ] . render ( xmlStream , model . language ) ;
53+ this . map [ " cp:keywords" ] . render ( xmlStream , model . keywords ) ;
54+ this . map [ " cp:category" ] . render ( xmlStream , model . category ) ;
55+ this . map [ " cp:lastModifiedBy" ] . render ( xmlStream , model . lastModifiedBy ) ;
56+ this . map [ " cp:lastPrinted" ] . render ( xmlStream , model . lastPrinted ) ;
57+ this . map [ " cp:revision" ] . render ( xmlStream , model . revision ) ;
58+ this . map [ " cp:version" ] . render ( xmlStream , model . version ) ;
59+ this . map [ " cp:contentStatus" ] . render ( xmlStream , model . contentStatus ) ;
60+ this . map [ " cp:contentType" ] . render ( xmlStream , model . contentType ) ;
61+ this . map [ " dcterms:created" ] . render ( xmlStream , model . created ) ;
62+ this . map [ " dcterms:modified" ] . render ( xmlStream , model . modified ) ;
6063
6164 xmlStream . closeNode ( ) ;
6265 }
@@ -67,16 +70,17 @@ class CoreXform extends BaseXform {
6770 return true ;
6871 }
6972 switch ( node . name ) {
70- case ' cp:coreProperties' :
71- case ' coreProperties' :
73+ case " cp:coreProperties" :
74+ case " coreProperties" :
7275 return true ;
7376 default :
7477 this . parser = this . map [ node . name ] ;
7578 if ( this . parser ) {
7679 this . parser . parseOpen ( node ) ;
7780 return true ;
7881 }
79- throw new Error ( `Unexpected xml node in parseOpen: ${ JSON . stringify ( node ) } ` ) ;
82+ // Ignore unknown tags for compatibility with non-Excel spreadsheet applications
83+ return false ;
8084 }
8185 }
8286
@@ -94,43 +98,45 @@ class CoreXform extends BaseXform {
9498 return true ;
9599 }
96100 switch ( name ) {
97- case ' cp:coreProperties' :
98- case ' coreProperties' :
101+ case " cp:coreProperties" :
102+ case " coreProperties" :
99103 this . model = {
100- creator : this . map [ ' dc:creator' ] . model ,
101- title : this . map [ ' dc:title' ] . model ,
102- subject : this . map [ ' dc:subject' ] . model ,
103- description : this . map [ ' dc:description' ] . model ,
104- identifier : this . map [ ' dc:identifier' ] . model ,
105- language : this . map [ ' dc:language' ] . model ,
106- keywords : this . map [ ' cp:keywords' ] . model ,
107- category : this . map [ ' cp:category' ] . model ,
108- lastModifiedBy : this . map [ ' cp:lastModifiedBy' ] . model ,
109- lastPrinted : this . map [ ' cp:lastPrinted' ] . model ,
110- revision : this . map [ ' cp:revision' ] . model ,
111- contentStatus : this . map [ ' cp:contentStatus' ] . model ,
112- contentType : this . map [ ' cp:contentType' ] . model ,
113- created : this . map [ ' dcterms:created' ] . model ,
114- modified : this . map [ ' dcterms:modified' ] . model ,
104+ creator : this . map [ " dc:creator" ] . model ,
105+ title : this . map [ " dc:title" ] . model ,
106+ subject : this . map [ " dc:subject" ] . model ,
107+ description : this . map [ " dc:description" ] . model ,
108+ identifier : this . map [ " dc:identifier" ] . model ,
109+ language : this . map [ " dc:language" ] . model ,
110+ keywords : this . map [ " cp:keywords" ] . model ,
111+ category : this . map [ " cp:category" ] . model ,
112+ lastModifiedBy : this . map [ " cp:lastModifiedBy" ] . model ,
113+ lastPrinted : this . map [ " cp:lastPrinted" ] . model ,
114+ revision : this . map [ " cp:revision" ] . model ,
115+ contentStatus : this . map [ " cp:contentStatus" ] . model ,
116+ contentType : this . map [ " cp:contentType" ] . model ,
117+ created : this . map [ " dcterms:created" ] . model ,
118+ modified : this . map [ " dcterms:modified" ] . model ,
115119 } ;
116120 return false ;
117121 default :
118- throw new Error ( `Unexpected xml node in parseClose: ${ name } ` ) ;
122+ // Ignore unknown tags for compatibility with non-Excel spreadsheet applications
123+ return true ;
119124 }
120125 }
121126}
122127
123- CoreXform . DateFormat = function ( dt ) {
124- return dt . toISOString ( ) . replace ( / [ . ] \d { 3 } / , '' ) ;
128+ CoreXform . DateFormat = function ( dt ) {
129+ return dt . toISOString ( ) . replace ( / [ . ] \d { 3 } / , "" ) ;
125130} ;
126- CoreXform . DateAttrs = { ' xsi:type' : ' dcterms:W3CDTF' } ;
131+ CoreXform . DateAttrs = { " xsi:type" : " dcterms:W3CDTF" } ;
127132
128133CoreXform . CORE_PROPERTY_ATTRIBUTES = {
129- 'xmlns:cp' : 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties' ,
130- 'xmlns:dc' : 'http://purl.org/dc/elements/1.1/' ,
131- 'xmlns:dcterms' : 'http://purl.org/dc/terms/' ,
132- 'xmlns:dcmitype' : 'http://purl.org/dc/dcmitype/' ,
133- 'xmlns:xsi' : 'http://www.w3.org/2001/XMLSchema-instance' ,
134+ "xmlns:cp" :
135+ "http://schemas.openxmlformats.org/package/2006/metadata/core-properties" ,
136+ "xmlns:dc" : "http://purl.org/dc/elements/1.1/" ,
137+ "xmlns:dcterms" : "http://purl.org/dc/terms/" ,
138+ "xmlns:dcmitype" : "http://purl.org/dc/dcmitype/" ,
139+ "xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance" ,
134140} ;
135141
136142module . exports = CoreXform ;
0 commit comments