Hi
I'm writing Sales Invoice to XML document in Axapta 4.0
I want to add namespaces 'cbc' and 'cac' to the elements where appropiate.
(cac = CommonAggregateComponents, cbc = CommonBasicComponents)
I have tried warius forms of "element = xmlDoc.createElement('cbc' + 'UBLVersionID');"
The problem is that when I call 'xmlDoc.save(somepath);' to write the XML file, the 'cbc:' part is ignored.
Here is a job showing my methods
static void Job350(Args _args)
{
XMLDocument xmlDoc;
XMLProcessingInstruction XMLpi;
XMLElement root;
XMLElement element;
xmlDoc = new XMLDocument();
root = xmlDoc.documentElement();
XMLpi = xmlDoc.createProcessingInstruction('xml', 'version=\"1.0\" encoding=\"ISO-8859-1\"');
xmlDoc.appendChild(XMLpi);
element = xmlDoc.createElement('Invoice');
element.setAttribute('xmlns', "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2");
element.setAttribute('xmlnscac', "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateCoomponents-2");
element.setAttribute('xmlnscbc', "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2");
element.setAttribute('xmlnsccts', "urn:un:unece:uncefact:documentation:2");
element.setAttribute('xmlnsext', "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2");
element.setAttribute('xmlnsqdt', "urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2");
element.setAttribute('xmlnsudt', "urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2");
element.setAttribute('xmlnsxsd', "http://www.w3.org/2001/XMLSchema");
element.setAttribute('xmlnsxsi', "http://www.w3.org/2001/XMLSchema-instance");
element.setAttribute('xsischemaLocation', "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2");
root = xmlDoc.appendChild(element);
element = xmlDoc.createElement('cbc:' + 'UBLVersionID');
element.text('2.0');
root.appendChild(element);
xmlDoc.save("C:\\Tmp\\Out.xml");
}
What I would like to get should look something like this
<?xml version="1.0" encoding="ISO-8859-1"?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlnscac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateCoomponents-2" xmlnscbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlnsccts="urn:un:unece:uncefact:documentation:2" xmlnsext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlnsqdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlnsudt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlnsxsd="http://www.w3.org/2001/XMLSchema" xmlnsxsi="http://www.w3.org/2001/XMLSchema-instance" xsischemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
<cbc:UBLVersionID>2.0</cbc:UBLVersionID>
</Invoice>
but the 'cbc:' part is skipped when I run the above code.
Does anyone have any ideas how to solve this??
I welkome any input.
Best regards,
Brynjar