@cj-tech-master/excelts 4.2.2-canary.20260115044841.88820eb → 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/browser/modules/excel/utils/parse-sax.d.ts +0 -3
  2. package/dist/browser/modules/excel/utils/parse-sax.js +13 -32
  3. package/dist/browser/modules/excel/xlsx/xform/core/app-xform.js +3 -3
  4. package/dist/browser/modules/excel/xlsx/xform/core/core-xform.js +68 -56
  5. package/dist/browser/modules/excel/xlsx/xform/list-xform.js +10 -8
  6. package/dist/browser/modules/excel/xlsx/xform/strings/shared-string-xform.js +3 -2
  7. package/dist/browser/modules/excel/xlsx/xform/strings/text-xform.js +7 -5
  8. package/dist/browser/modules/excel/xlsx/xlsx.browser.js +4 -8
  9. package/dist/cjs/modules/excel/utils/parse-sax.js +13 -32
  10. package/dist/cjs/modules/excel/xlsx/xform/core/app-xform.js +3 -3
  11. package/dist/cjs/modules/excel/xlsx/xform/core/core-xform.js +68 -56
  12. package/dist/cjs/modules/excel/xlsx/xform/list-xform.js +10 -8
  13. package/dist/cjs/modules/excel/xlsx/xform/strings/shared-string-xform.js +3 -2
  14. package/dist/cjs/modules/excel/xlsx/xform/strings/text-xform.js +7 -5
  15. package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +4 -8
  16. package/dist/esm/modules/excel/utils/parse-sax.js +13 -32
  17. package/dist/esm/modules/excel/xlsx/xform/core/app-xform.js +3 -3
  18. package/dist/esm/modules/excel/xlsx/xform/core/core-xform.js +68 -56
  19. package/dist/esm/modules/excel/xlsx/xform/list-xform.js +10 -8
  20. package/dist/esm/modules/excel/xlsx/xform/strings/shared-string-xform.js +3 -2
  21. package/dist/esm/modules/excel/xlsx/xform/strings/text-xform.js +7 -5
  22. package/dist/esm/modules/excel/xlsx/xlsx.browser.js +4 -8
  23. package/dist/iife/excelts.iife.js +100 -100
  24. package/dist/iife/excelts.iife.js.map +1 -1
  25. package/dist/iife/excelts.iife.min.js +24 -24
  26. package/dist/types/modules/excel/utils/parse-sax.d.ts +0 -3
  27. package/package.json +1 -1
@@ -6,50 +6,31 @@ const base_xform_1 = require("../base-xform.js");
6
6
  const date_xform_1 = require("../simple/date-xform.js");
7
7
  const string_xform_1 = require("../simple/string-xform.js");
8
8
  const integer_xform_1 = require("../simple/integer-xform.js");
9
- // Rendering uses namespace prefixes, parsing uses unqualified names (SAX strips prefixes)
10
- const PROPS = {
11
- creator: "dc:creator",
12
- title: "dc:title",
13
- subject: "dc:subject",
14
- description: "dc:description",
15
- identifier: "dc:identifier",
16
- language: "dc:language",
17
- keywords: "cp:keywords",
18
- category: "cp:category",
19
- lastModifiedBy: "cp:lastModifiedBy",
20
- lastPrinted: "cp:lastPrinted",
21
- revision: "cp:revision",
22
- version: "cp:version",
23
- contentStatus: "cp:contentStatus",
24
- contentType: "cp:contentType",
25
- created: "dcterms:created",
26
- modified: "dcterms:modified"
27
- };
28
9
  class CoreXform extends base_xform_1.BaseXform {
29
10
  constructor() {
30
11
  super();
31
12
  this.map = {
32
- creator: new string_xform_1.StringXform({ tag: PROPS.creator }),
33
- title: new string_xform_1.StringXform({ tag: PROPS.title }),
34
- subject: new string_xform_1.StringXform({ tag: PROPS.subject }),
35
- description: new string_xform_1.StringXform({ tag: PROPS.description }),
36
- identifier: new string_xform_1.StringXform({ tag: PROPS.identifier }),
37
- language: new string_xform_1.StringXform({ tag: PROPS.language }),
38
- keywords: new string_xform_1.StringXform({ tag: PROPS.keywords }),
39
- category: new string_xform_1.StringXform({ tag: PROPS.category }),
40
- lastModifiedBy: new string_xform_1.StringXform({ tag: PROPS.lastModifiedBy }),
41
- lastPrinted: new date_xform_1.DateXform({ tag: PROPS.lastPrinted, format: CoreXform.DateFormat }),
42
- revision: new integer_xform_1.IntegerXform({ tag: PROPS.revision }),
43
- version: new string_xform_1.StringXform({ tag: PROPS.version }),
44
- contentStatus: new string_xform_1.StringXform({ tag: PROPS.contentStatus }),
45
- contentType: new string_xform_1.StringXform({ tag: PROPS.contentType }),
46
- created: new date_xform_1.DateXform({
47
- tag: PROPS.created,
13
+ "dc:creator": new string_xform_1.StringXform({ tag: "dc:creator" }),
14
+ "dc:title": new string_xform_1.StringXform({ tag: "dc:title" }),
15
+ "dc:subject": new string_xform_1.StringXform({ tag: "dc:subject" }),
16
+ "dc:description": new string_xform_1.StringXform({ tag: "dc:description" }),
17
+ "dc:identifier": new string_xform_1.StringXform({ tag: "dc:identifier" }),
18
+ "dc:language": new string_xform_1.StringXform({ tag: "dc:language" }),
19
+ "cp:keywords": new string_xform_1.StringXform({ tag: "cp:keywords" }),
20
+ "cp:category": new string_xform_1.StringXform({ tag: "cp:category" }),
21
+ "cp:lastModifiedBy": new string_xform_1.StringXform({ tag: "cp:lastModifiedBy" }),
22
+ "cp:lastPrinted": new date_xform_1.DateXform({ tag: "cp:lastPrinted", format: CoreXform.DateFormat }),
23
+ "cp:revision": new integer_xform_1.IntegerXform({ tag: "cp:revision" }),
24
+ "cp:version": new string_xform_1.StringXform({ tag: "cp:version" }),
25
+ "cp:contentStatus": new string_xform_1.StringXform({ tag: "cp:contentStatus" }),
26
+ "cp:contentType": new string_xform_1.StringXform({ tag: "cp:contentType" }),
27
+ "dcterms:created": new date_xform_1.DateXform({
28
+ tag: "dcterms:created",
48
29
  attrs: CoreXform.DateAttrs,
49
30
  format: CoreXform.DateFormat
50
31
  }),
51
- modified: new date_xform_1.DateXform({
52
- tag: PROPS.modified,
32
+ "dcterms:modified": new date_xform_1.DateXform({
33
+ tag: "dcterms:modified",
53
34
  attrs: CoreXform.DateAttrs,
54
35
  format: CoreXform.DateFormat
55
36
  })
@@ -58,9 +39,22 @@ class CoreXform extends base_xform_1.BaseXform {
58
39
  render(xmlStream, model) {
59
40
  xmlStream.openXml(xml_stream_1.XmlStream.StdDocAttributes);
60
41
  xmlStream.openNode("cp:coreProperties", CoreXform.CORE_PROPERTY_ATTRIBUTES);
61
- for (const key of Object.keys(PROPS)) {
62
- this.map[key].render(xmlStream, model[key]);
63
- }
42
+ this.map["dc:creator"].render(xmlStream, model.creator);
43
+ this.map["dc:title"].render(xmlStream, model.title);
44
+ this.map["dc:subject"].render(xmlStream, model.subject);
45
+ this.map["dc:description"].render(xmlStream, model.description);
46
+ this.map["dc:identifier"].render(xmlStream, model.identifier);
47
+ this.map["dc:language"].render(xmlStream, model.language);
48
+ this.map["cp:keywords"].render(xmlStream, model.keywords);
49
+ this.map["cp:category"].render(xmlStream, model.category);
50
+ this.map["cp:lastModifiedBy"].render(xmlStream, model.lastModifiedBy);
51
+ this.map["cp:lastPrinted"].render(xmlStream, model.lastPrinted);
52
+ this.map["cp:revision"].render(xmlStream, model.revision);
53
+ this.map["cp:version"].render(xmlStream, model.version);
54
+ this.map["cp:contentStatus"].render(xmlStream, model.contentStatus);
55
+ this.map["cp:contentType"].render(xmlStream, model.contentType);
56
+ this.map["dcterms:created"].render(xmlStream, model.created);
57
+ this.map["dcterms:modified"].render(xmlStream, model.modified);
64
58
  xmlStream.closeNode();
65
59
  }
66
60
  parseOpen(node) {
@@ -68,13 +62,18 @@ class CoreXform extends base_xform_1.BaseXform {
68
62
  this.parser.parseOpen(node);
69
63
  return true;
70
64
  }
71
- if (node.name !== "coreProperties") {
72
- this.parser = this.map[node.name];
73
- if (this.parser) {
74
- this.parser.parseOpen(node);
75
- }
65
+ switch (node.name) {
66
+ case "cp:coreProperties":
67
+ case "coreProperties":
68
+ return true;
69
+ default:
70
+ this.parser = this.map[node.name];
71
+ if (this.parser) {
72
+ this.parser.parseOpen(node);
73
+ return true;
74
+ }
75
+ throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(node)}`);
76
76
  }
77
- return true;
78
77
  }
79
78
  parseText(text) {
80
79
  if (this.parser) {
@@ -88,17 +87,30 @@ class CoreXform extends base_xform_1.BaseXform {
88
87
  }
89
88
  return true;
90
89
  }
91
- if (name === "coreProperties") {
92
- this.model = {};
93
- for (const key of Object.keys(PROPS)) {
94
- const val = this.map[key].model;
95
- if (val !== undefined && val !== "") {
96
- this.model[key] = val;
97
- }
98
- }
99
- return false;
90
+ switch (name) {
91
+ case "cp:coreProperties":
92
+ case "coreProperties":
93
+ this.model = {
94
+ creator: this.map["dc:creator"].model,
95
+ title: this.map["dc:title"].model,
96
+ subject: this.map["dc:subject"].model,
97
+ description: this.map["dc:description"].model,
98
+ identifier: this.map["dc:identifier"].model,
99
+ language: this.map["dc:language"].model,
100
+ keywords: this.map["cp:keywords"].model,
101
+ category: this.map["cp:category"].model,
102
+ lastModifiedBy: this.map["cp:lastModifiedBy"].model,
103
+ lastPrinted: this.map["cp:lastPrinted"].model,
104
+ revision: this.map["cp:revision"].model,
105
+ contentStatus: this.map["cp:contentStatus"].model,
106
+ contentType: this.map["cp:contentType"].model,
107
+ created: this.map["dcterms:created"].model,
108
+ modified: this.map["dcterms:modified"].model
109
+ };
110
+ return false;
111
+ default:
112
+ throw new Error(`Unexpected xml node in parseClose: ${name}`);
100
113
  }
101
- return true;
102
114
  }
103
115
  }
104
116
  exports.CoreXform = CoreXform;
@@ -44,15 +44,17 @@ class ListXform extends base_xform_1.BaseXform {
44
44
  this.parser.parseOpen(node);
45
45
  return true;
46
46
  }
47
- if (node.name === this.tag) {
48
- this.model = [];
49
- return true;
50
- }
51
- if (this.childXform.parseOpen(node)) {
52
- this.parser = this.childXform;
53
- return true;
47
+ switch (node.name) {
48
+ case this.tag:
49
+ this.model = [];
50
+ return true;
51
+ default:
52
+ if (this.childXform.parseOpen(node)) {
53
+ this.parser = this.childXform;
54
+ return true;
55
+ }
56
+ return false;
54
57
  }
55
- return false;
56
58
  }
57
59
  parseText(text) {
58
60
  if (this.parser) {
@@ -39,15 +39,16 @@ class SharedStringXform extends base_xform_1.BaseXform {
39
39
  xmlStream.closeNode();
40
40
  }
41
41
  parseOpen(node) {
42
+ const { name } = node;
42
43
  if (this.parser) {
43
44
  this.parser.parseOpen(node);
44
45
  return true;
45
46
  }
46
- if (node.name === this.tag) {
47
+ if (name === this.tag) {
47
48
  this.model = {};
48
49
  return true;
49
50
  }
50
- this.parser = this.map[node.name];
51
+ this.parser = this.map[name];
51
52
  if (this.parser) {
52
53
  this.parser.parseOpen(node);
53
54
  return true;
@@ -16,12 +16,14 @@ class TextXform extends base_xform_1.BaseXform {
16
16
  xmlStream.closeNode();
17
17
  }
18
18
  parseOpen(node) {
19
- if (node.name === "t") {
20
- this._text = [];
21
- this.model = "";
22
- return true;
19
+ switch (node.name) {
20
+ case "t":
21
+ this._text = [];
22
+ this.model = ""; // Initialize model to empty string
23
+ return true;
24
+ default:
25
+ return false;
23
26
  }
24
- return false;
25
27
  }
26
28
  parseText(text) {
27
29
  this._text.push(text);
@@ -367,10 +367,8 @@ class XLSX {
367
367
  case ooxml_paths_1.OOXML_PATHS.docPropsApp: {
368
368
  const appXform = new app_xform_1.AppXform();
369
369
  const appProperties = await appXform.parseStream(stream);
370
- if (appProperties) {
371
- model.company = appProperties.company;
372
- model.manager = appProperties.manager;
373
- }
370
+ model.company = appProperties.company;
371
+ model.manager = appProperties.manager;
374
372
  break;
375
373
  }
376
374
  case ooxml_paths_1.OOXML_PATHS.docPropsCore: {
@@ -832,10 +830,8 @@ class XLSX {
832
830
  case ooxml_paths_1.OOXML_PATHS.docPropsApp: {
833
831
  const appXform = new app_xform_1.AppXform();
834
832
  const appProperties = await appXform.parseStream(stream);
835
- if (appProperties) {
836
- model.company = appProperties.company;
837
- model.manager = appProperties.manager;
838
- }
833
+ model.company = appProperties.company;
834
+ model.manager = appProperties.manager;
839
835
  break;
840
836
  }
841
837
  case ooxml_paths_1.OOXML_PATHS.docPropsCore: {
@@ -142,12 +142,6 @@ const XML_ENTITIES = {
142
142
  quot: '"',
143
143
  apos: "'"
144
144
  };
145
- // HAN CELL namespace prefix normalization
146
- // HAN CELL uses non-standard namespace prefixes (ep:, cp:, dc:, etc.)
147
- // The x: prefix for spreadsheetml is detected dynamically from xmlns declarations
148
- // See: https://github.com/exceljs/exceljs/issues/3014
149
- const HAN_CELL_PREFIXES = /^(ep|cp|dc|dcterms|dcmitype|vt):/;
150
- const SPREADSHEETML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
151
145
  // ============================================================================
152
146
  // Parser States
153
147
  // ============================================================================
@@ -208,8 +202,6 @@ export class SaxesParser {
208
202
  this.chunkPosition = 0;
209
203
  // Entity storage
210
204
  this.ENTITIES = { ...XML_ENTITIES };
211
- // HAN CELL compatibility: spreadsheetml namespace prefix (e.g., "x")
212
- this.nsPrefix = null;
213
205
  this.trackPosition = opt?.position !== false;
214
206
  this.fileName = opt?.fileName;
215
207
  this.fragment = opt?.fragment ?? false;
@@ -244,14 +236,6 @@ export class SaxesParser {
244
236
  this.chunk = "";
245
237
  this.i = 0;
246
238
  this.prevI = 0;
247
- this.nsPrefix = null;
248
- }
249
- // Strip HAN CELL namespace prefixes from element names
250
- stripNsPrefix(name) {
251
- const n = name.replace(HAN_CELL_PREFIXES, "");
252
- return this.nsPrefix && n.startsWith(this.nsPrefix + ":")
253
- ? n.slice(this.nsPrefix.length + 1)
254
- : n;
255
239
  }
256
240
  on(name, handler) {
257
241
  switch (name) {
@@ -667,8 +651,9 @@ export class SaxesParser {
667
651
  this.name += charFromCode(c);
668
652
  return;
669
653
  }
654
+ // Tag name complete
670
655
  this.tag = {
671
- name: this.stripNsPrefix(this.name),
656
+ name: this.name,
672
657
  attributes: Object.create(null),
673
658
  isSelfClosing: false
674
659
  };
@@ -1107,7 +1092,11 @@ export class SaxesParser {
1107
1092
  openTag() {
1108
1093
  const tag = this.tag;
1109
1094
  tag.isSelfClosing = false;
1110
- this.processAttributes(tag);
1095
+ // Copy attributes from list to object
1096
+ for (const { name, value } of this.attribList) {
1097
+ tag.attributes[name] = value;
1098
+ }
1099
+ this.attribList = [];
1111
1100
  this.openTagHandler?.(tag);
1112
1101
  this.tags.push(tag);
1113
1102
  this.name = "";
@@ -1116,7 +1105,11 @@ export class SaxesParser {
1116
1105
  openSelfClosingTag() {
1117
1106
  const tag = this.tag;
1118
1107
  tag.isSelfClosing = true;
1119
- this.processAttributes(tag);
1108
+ // Copy attributes from list to object
1109
+ for (const { name, value } of this.attribList) {
1110
+ tag.attributes[name] = value;
1111
+ }
1112
+ this.attribList = [];
1120
1113
  this.openTagHandler?.(tag);
1121
1114
  this.closeTagHandler?.(tag);
1122
1115
  if (this.tags.length === 0) {
@@ -1125,20 +1118,8 @@ export class SaxesParser {
1125
1118
  this.name = "";
1126
1119
  this.state = S_TEXT;
1127
1120
  }
1128
- // Process attributes and detect spreadsheetml namespace prefix
1129
- processAttributes(tag) {
1130
- for (const { name, value } of this.attribList) {
1131
- tag.attributes[name] = value;
1132
- if (name.startsWith("xmlns:") && value === SPREADSHEETML_NS) {
1133
- this.nsPrefix = name.slice(6);
1134
- tag.name = this.stripNsPrefix(tag.name);
1135
- }
1136
- }
1137
- this.attribList = [];
1138
- }
1139
1121
  closeTag() {
1140
- const { tags } = this;
1141
- const name = this.stripNsPrefix(this.name);
1122
+ const { tags, name } = this;
1142
1123
  this.state = S_TEXT;
1143
1124
  this.name = "";
1144
1125
  if (name === "") {
@@ -10,7 +10,7 @@ class AppXform extends BaseXform {
10
10
  Company: new StringXform({ tag: "Company" }),
11
11
  Manager: new StringXform({ tag: "Manager" }),
12
12
  HeadingPairs: new AppHeadingPairsXform(),
13
- TitlesOfParts: new AppTitlesOfPartsXform()
13
+ TitleOfParts: new AppTitlesOfPartsXform()
14
14
  };
15
15
  }
16
16
  render(xmlStream, model) {
@@ -20,7 +20,7 @@ class AppXform extends BaseXform {
20
20
  xmlStream.leafNode("DocSecurity", undefined, "0");
21
21
  xmlStream.leafNode("ScaleCrop", undefined, "false");
22
22
  this.map.HeadingPairs.render(xmlStream, model.worksheets);
23
- this.map.TitlesOfParts.render(xmlStream, model.worksheets);
23
+ this.map.TitleOfParts.render(xmlStream, model.worksheets);
24
24
  this.map.Company.render(xmlStream, model.company || "");
25
25
  this.map.Manager.render(xmlStream, model.manager);
26
26
  xmlStream.leafNode("LinksUpToDate", undefined, "false");
@@ -62,7 +62,7 @@ class AppXform extends BaseXform {
62
62
  switch (name) {
63
63
  case "Properties":
64
64
  this.model = {
65
- worksheets: this.map.TitlesOfParts.model,
65
+ worksheets: this.map.TitleOfParts.model,
66
66
  company: this.map.Company.model,
67
67
  manager: this.map.Manager.model
68
68
  };
@@ -3,50 +3,31 @@ import { BaseXform } from "../base-xform.js";
3
3
  import { DateXform } from "../simple/date-xform.js";
4
4
  import { StringXform } from "../simple/string-xform.js";
5
5
  import { IntegerXform } from "../simple/integer-xform.js";
6
- // Rendering uses namespace prefixes, parsing uses unqualified names (SAX strips prefixes)
7
- const PROPS = {
8
- creator: "dc:creator",
9
- title: "dc:title",
10
- subject: "dc:subject",
11
- description: "dc:description",
12
- identifier: "dc:identifier",
13
- language: "dc:language",
14
- keywords: "cp:keywords",
15
- category: "cp:category",
16
- lastModifiedBy: "cp:lastModifiedBy",
17
- lastPrinted: "cp:lastPrinted",
18
- revision: "cp:revision",
19
- version: "cp:version",
20
- contentStatus: "cp:contentStatus",
21
- contentType: "cp:contentType",
22
- created: "dcterms:created",
23
- modified: "dcterms:modified"
24
- };
25
6
  class CoreXform extends BaseXform {
26
7
  constructor() {
27
8
  super();
28
9
  this.map = {
29
- creator: new StringXform({ tag: PROPS.creator }),
30
- title: new StringXform({ tag: PROPS.title }),
31
- subject: new StringXform({ tag: PROPS.subject }),
32
- description: new StringXform({ tag: PROPS.description }),
33
- identifier: new StringXform({ tag: PROPS.identifier }),
34
- language: new StringXform({ tag: PROPS.language }),
35
- keywords: new StringXform({ tag: PROPS.keywords }),
36
- category: new StringXform({ tag: PROPS.category }),
37
- lastModifiedBy: new StringXform({ tag: PROPS.lastModifiedBy }),
38
- lastPrinted: new DateXform({ tag: PROPS.lastPrinted, format: CoreXform.DateFormat }),
39
- revision: new IntegerXform({ tag: PROPS.revision }),
40
- version: new StringXform({ tag: PROPS.version }),
41
- contentStatus: new StringXform({ tag: PROPS.contentStatus }),
42
- contentType: new StringXform({ tag: PROPS.contentType }),
43
- created: new DateXform({
44
- tag: PROPS.created,
10
+ "dc:creator": new StringXform({ tag: "dc:creator" }),
11
+ "dc:title": new StringXform({ tag: "dc:title" }),
12
+ "dc:subject": new StringXform({ tag: "dc:subject" }),
13
+ "dc:description": new StringXform({ tag: "dc:description" }),
14
+ "dc:identifier": new StringXform({ tag: "dc:identifier" }),
15
+ "dc:language": new StringXform({ tag: "dc:language" }),
16
+ "cp:keywords": new StringXform({ tag: "cp:keywords" }),
17
+ "cp:category": new StringXform({ tag: "cp:category" }),
18
+ "cp:lastModifiedBy": new StringXform({ tag: "cp:lastModifiedBy" }),
19
+ "cp:lastPrinted": new DateXform({ tag: "cp:lastPrinted", format: CoreXform.DateFormat }),
20
+ "cp:revision": new IntegerXform({ tag: "cp:revision" }),
21
+ "cp:version": new StringXform({ tag: "cp:version" }),
22
+ "cp:contentStatus": new StringXform({ tag: "cp:contentStatus" }),
23
+ "cp:contentType": new StringXform({ tag: "cp:contentType" }),
24
+ "dcterms:created": new DateXform({
25
+ tag: "dcterms:created",
45
26
  attrs: CoreXform.DateAttrs,
46
27
  format: CoreXform.DateFormat
47
28
  }),
48
- modified: new DateXform({
49
- tag: PROPS.modified,
29
+ "dcterms:modified": new DateXform({
30
+ tag: "dcterms:modified",
50
31
  attrs: CoreXform.DateAttrs,
51
32
  format: CoreXform.DateFormat
52
33
  })
@@ -55,9 +36,22 @@ class CoreXform extends BaseXform {
55
36
  render(xmlStream, model) {
56
37
  xmlStream.openXml(XmlStream.StdDocAttributes);
57
38
  xmlStream.openNode("cp:coreProperties", CoreXform.CORE_PROPERTY_ATTRIBUTES);
58
- for (const key of Object.keys(PROPS)) {
59
- this.map[key].render(xmlStream, model[key]);
60
- }
39
+ this.map["dc:creator"].render(xmlStream, model.creator);
40
+ this.map["dc:title"].render(xmlStream, model.title);
41
+ this.map["dc:subject"].render(xmlStream, model.subject);
42
+ this.map["dc:description"].render(xmlStream, model.description);
43
+ this.map["dc:identifier"].render(xmlStream, model.identifier);
44
+ this.map["dc:language"].render(xmlStream, model.language);
45
+ this.map["cp:keywords"].render(xmlStream, model.keywords);
46
+ this.map["cp:category"].render(xmlStream, model.category);
47
+ this.map["cp:lastModifiedBy"].render(xmlStream, model.lastModifiedBy);
48
+ this.map["cp:lastPrinted"].render(xmlStream, model.lastPrinted);
49
+ this.map["cp:revision"].render(xmlStream, model.revision);
50
+ this.map["cp:version"].render(xmlStream, model.version);
51
+ this.map["cp:contentStatus"].render(xmlStream, model.contentStatus);
52
+ this.map["cp:contentType"].render(xmlStream, model.contentType);
53
+ this.map["dcterms:created"].render(xmlStream, model.created);
54
+ this.map["dcterms:modified"].render(xmlStream, model.modified);
61
55
  xmlStream.closeNode();
62
56
  }
63
57
  parseOpen(node) {
@@ -65,13 +59,18 @@ class CoreXform extends BaseXform {
65
59
  this.parser.parseOpen(node);
66
60
  return true;
67
61
  }
68
- if (node.name !== "coreProperties") {
69
- this.parser = this.map[node.name];
70
- if (this.parser) {
71
- this.parser.parseOpen(node);
72
- }
62
+ switch (node.name) {
63
+ case "cp:coreProperties":
64
+ case "coreProperties":
65
+ return true;
66
+ default:
67
+ this.parser = this.map[node.name];
68
+ if (this.parser) {
69
+ this.parser.parseOpen(node);
70
+ return true;
71
+ }
72
+ throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(node)}`);
73
73
  }
74
- return true;
75
74
  }
76
75
  parseText(text) {
77
76
  if (this.parser) {
@@ -85,17 +84,30 @@ class CoreXform extends BaseXform {
85
84
  }
86
85
  return true;
87
86
  }
88
- if (name === "coreProperties") {
89
- this.model = {};
90
- for (const key of Object.keys(PROPS)) {
91
- const val = this.map[key].model;
92
- if (val !== undefined && val !== "") {
93
- this.model[key] = val;
94
- }
95
- }
96
- return false;
87
+ switch (name) {
88
+ case "cp:coreProperties":
89
+ case "coreProperties":
90
+ this.model = {
91
+ creator: this.map["dc:creator"].model,
92
+ title: this.map["dc:title"].model,
93
+ subject: this.map["dc:subject"].model,
94
+ description: this.map["dc:description"].model,
95
+ identifier: this.map["dc:identifier"].model,
96
+ language: this.map["dc:language"].model,
97
+ keywords: this.map["cp:keywords"].model,
98
+ category: this.map["cp:category"].model,
99
+ lastModifiedBy: this.map["cp:lastModifiedBy"].model,
100
+ lastPrinted: this.map["cp:lastPrinted"].model,
101
+ revision: this.map["cp:revision"].model,
102
+ contentStatus: this.map["cp:contentStatus"].model,
103
+ contentType: this.map["cp:contentType"].model,
104
+ created: this.map["dcterms:created"].model,
105
+ modified: this.map["dcterms:modified"].model
106
+ };
107
+ return false;
108
+ default:
109
+ throw new Error(`Unexpected xml node in parseClose: ${name}`);
97
110
  }
98
- return true;
99
111
  }
100
112
  }
101
113
  CoreXform.DateFormat = function (dt) {
@@ -41,15 +41,17 @@ class ListXform extends BaseXform {
41
41
  this.parser.parseOpen(node);
42
42
  return true;
43
43
  }
44
- if (node.name === this.tag) {
45
- this.model = [];
46
- return true;
47
- }
48
- if (this.childXform.parseOpen(node)) {
49
- this.parser = this.childXform;
50
- return true;
44
+ switch (node.name) {
45
+ case this.tag:
46
+ this.model = [];
47
+ return true;
48
+ default:
49
+ if (this.childXform.parseOpen(node)) {
50
+ this.parser = this.childXform;
51
+ return true;
52
+ }
53
+ return false;
51
54
  }
52
- return false;
53
55
  }
54
56
  parseText(text) {
55
57
  if (this.parser) {
@@ -36,15 +36,16 @@ class SharedStringXform extends BaseXform {
36
36
  xmlStream.closeNode();
37
37
  }
38
38
  parseOpen(node) {
39
+ const { name } = node;
39
40
  if (this.parser) {
40
41
  this.parser.parseOpen(node);
41
42
  return true;
42
43
  }
43
- if (node.name === this.tag) {
44
+ if (name === this.tag) {
44
45
  this.model = {};
45
46
  return true;
46
47
  }
47
- this.parser = this.map[node.name];
48
+ this.parser = this.map[name];
48
49
  if (this.parser) {
49
50
  this.parser.parseOpen(node);
50
51
  return true;
@@ -13,12 +13,14 @@ class TextXform extends BaseXform {
13
13
  xmlStream.closeNode();
14
14
  }
15
15
  parseOpen(node) {
16
- if (node.name === "t") {
17
- this._text = [];
18
- this.model = "";
19
- return true;
16
+ switch (node.name) {
17
+ case "t":
18
+ this._text = [];
19
+ this.model = ""; // Initialize model to empty string
20
+ return true;
21
+ default:
22
+ return false;
20
23
  }
21
- return false;
22
24
  }
23
25
  parseText(text) {
24
26
  this._text.push(text);
@@ -364,10 +364,8 @@ class XLSX {
364
364
  case OOXML_PATHS.docPropsApp: {
365
365
  const appXform = new AppXform();
366
366
  const appProperties = await appXform.parseStream(stream);
367
- if (appProperties) {
368
- model.company = appProperties.company;
369
- model.manager = appProperties.manager;
370
- }
367
+ model.company = appProperties.company;
368
+ model.manager = appProperties.manager;
371
369
  break;
372
370
  }
373
371
  case OOXML_PATHS.docPropsCore: {
@@ -829,10 +827,8 @@ class XLSX {
829
827
  case OOXML_PATHS.docPropsApp: {
830
828
  const appXform = new AppXform();
831
829
  const appProperties = await appXform.parseStream(stream);
832
- if (appProperties) {
833
- model.company = appProperties.company;
834
- model.manager = appProperties.manager;
835
- }
830
+ model.company = appProperties.company;
831
+ model.manager = appProperties.manager;
836
832
  break;
837
833
  }
838
834
  case OOXML_PATHS.docPropsCore: {