Skip to content
Open
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
32 changes: 22 additions & 10 deletions src/wsdl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ export class WSDL {
return saxStream;
}






public xmlToObject(xml, callback?) {
const p: any = typeof callback === 'function' ? {} : sax.parser(true, null);
let objectName = null;
Expand Down Expand Up @@ -351,25 +356,32 @@ export class WSDL {
const topObject = top.object;
const topSchema = top.schema;
const name = splitQName(nsName).name;

if (typeof cur.schema === 'string' && (cur.schema === 'string' || cur.schema.split(':')[1] === 'string')) {
if (typeof obj === 'object' && Object.keys(obj).length === 0) {
obj = cur.object = (this.options.preserveWhitespace ? cur.text || '' : '');
}
}


// Handle nil attribute properly while preserving other attributes
if (cur.nil === true) {
if (this.options.handleNilAsNull) {
obj = null;
// Check for NV == 7701003 attribute and skip handling if match is found
const attributes = obj[this.options.attributesKey];
if (attributes && attributes.NV === '7701003') {
return; // Skip further processing of this element
}

// Store null value in the valueKey instead of replacing the entire object
if (attributes) {
// Keep attributes, no other changes
} else {
return;
// If there are no attributes, set the object to null
obj = null;
}
}

if (_.isPlainObject(obj) && !Object.keys(obj).length) {
} else if (_.isPlainObject(obj) && !Object.keys(obj).length) {
obj = null;
}

if (topSchema && topSchema[name + '[]']) {
if (!topObject[name]) {
topObject[name] = [];
Expand All @@ -383,7 +395,7 @@ export class WSDL {
} else {
topObject[name] = obj;
}

if (cur.id) {
refs[cur.id].obj = obj;
}
Expand Down
Loading