diff --git a/__data__/202510/wsdl_112.xsd b/__data__/202510/wsdl_112.xsd new file mode 100644 index 0000000..caad1b4 --- /dev/null +++ b/__data__/202510/wsdl_112.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + diff --git a/__tests__/XMLMarshaller.js b/__tests__/XMLMarshaller.js index 23b4e2e..479eba3 100644 --- a/__tests__/XMLMarshaller.js +++ b/__tests__/XMLMarshaller.js @@ -315,6 +315,31 @@ test ('nillable', () => { }) +test ('form="unqualified"', () => { + + const xsdPath = Path.join (__dirname, '..', '__data__', '202510', 'wsdl_112.xsd') + + const xs = getXSSync (xsdPath) + + function stringify (data, options) { + + const xml = xs.createMarshaller ('UpdateCardResponse', 'http://eiim.service112.iskratel.si/').stringify (data, options) + + execSync (`xmllint --schema ${xsdPath} -`, {input: xml, stdio: 'pipe'}) + + return xml + + } + + let xml = stringify ({ + "Code": 200, + "CodeDescr": "Descr" + }) + + expect (xml).toMatch ('200Descr') + +}) + test ('att simple type', () => { const xsdPath = Path.join (__dirname, '..', '__data__', 'att.xsd') diff --git a/lib/XMLSchema.js b/lib/XMLSchema.js index f5b2a9b..a114ecd 100644 --- a/lib/XMLSchema.js +++ b/lib/XMLSchema.js @@ -110,18 +110,18 @@ const XMLSchema = class extends Map { const {localName} = node for (const e of node.children) this.copyTargetNamespace (e, localName === 'schema') - + const {formDefault} = this; if (!(localName in formDefault)) return - + if (!force) { - - const {form} = node.attributes - - if (form !== FORM_Q && formDefault [localName] !== FORM_Q) return + + const form = node.attributes?.form || formDefault [localName] + + if (form !== FORM_Q) return } - node.targetNamespace = this.targetNamespace + node.targetNamespace = this.targetNamespace }