Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 56 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"dependencies": {
"@typed-mxgraph/typed-mxgraph": "~1.0.8",
"es-toolkit": "~1.45.0",
"fast-xml-parser": "5.4.2",
"fast-xml-parser": "5.5.10",
"mxgraph": "4.2.2"
},
"devDependencies": {
Expand Down
21 changes: 15 additions & 6 deletions src/component/parser/xml/BpmnXmlParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,25 @@ export default class BpmnXmlParser {
*/
processEntities: false,

// See https://github.com/NaturalIntelligence/fast-xml-parser/blob/v4.3.4/docs/v4/2.XMLparseOptions.md#attributevalueprocessor
attributeValueProcessor: (name: string, value: string, nodePath: string): unknown => {
if (isNumeric(name, nodePath)) {
// Use Matcher object (jPath: false) to get paths without namespace prefixes via toString('.', false).
// With jPath: true (default), toString() includes namespace prefixes (e.g. "bpmn:definitions.bpmndi:BPMNDiagram")
// which don't match our expected paths in nodesWithNumericAttributes.
jPath: false,

// See https://github.com/NaturalIntelligence/fast-xml-parser/blob/v5.5.7/docs/v4%2C%20v5/2.XMLparseOptions.md#attributevalueprocessor
attributeValueProcessor: (attributeName: string, attributeValue: string, nodePathOrMatcher: unknown): unknown => {
// nodePathOrMatcher is a Matcher instance (jPath: false) or a string (jPath: true). Get path without namespace prefixes.
const nodePath =
typeof nodePathOrMatcher === 'string' ? nodePathOrMatcher : (nodePathOrMatcher as { toString(separator?: string, includeNs?: boolean): string }).toString('.', false);

if (isNumeric(attributeName, nodePath)) {
// The strnum lib used by fast-xml-parser is not able to parse all numbers
// The only available options are https://github.com/NaturalIntelligence/fast-xml-parser/blob/v4.3.4/docs/v4/2.XMLparseOptions.md#numberparseoptions
// The only available options are https://github.com/NaturalIntelligence/fast-xml-parser/blob/v5.5.7/docs/v4%2C%20v5/2.XMLparseOptions.md#numberparseoptions
// This is a fix for https://github.com/process-analytics/bpmn-visualization-js/issues/2857
return Number(value);
return Number(attributeValue);
}

return this.processAttribute(value);
return this.processAttribute(attributeValue);
},
};
private readonly xmlParser: XMLParser = new XMLParser(this.x2jOptions);
Expand Down
Loading