The Xml Attribute "Xmlns" Gets Added To More Xml Elements Than Defined (Doc ID 866908.1)

Last updated on OCTOBER 19, 2016

Applies to:

LODESTAR EIP - Version: 1.5.0 and later   [Release: 1.5 and later ]
Information in this document applies to any platform.

Goal

Explain the reason why, when defining the XML attribute "xmlns" only on the XML element "importFile",  the attribute also gets added to the child element of "importFile".

Consider the following code:

//
//
XML_ELEMENT IMPORTFILE NODENAME "importFile";
XML_ELEMENT TRADEIMPORT NODENAME "tradeImport" PARENT IMPORTFILE;
XML_ELEMENT ZAINETKEY NODENAME "zkey" PARENT TRADEIMPORT;
//
//Create XML
//
XML_OP CREATE IMPORTFILE;
W523_HEAD_XML = DOMDOCADDPI(IMPORTFILE , "xml" , "version=""1.0"" encoding=""UTF-8""");
W523_IMPORTFILE_ATTR_XMLNS = DOMNODESETATTRIBUTE(IMPORTFILE , "xmlns" , "http://DealImporter/Importer");
W523_IMPORTFILE_ATTR_TEMPLATE = DOMNODESETATTRIBUTE(IMPORTFILE , "template" , "Default");
W523_IMPORTFILE_ATTR_DATEFMT = DOMNODESETATTRIBUTE(IMPORTFILE , "dateFmt" , "YYYYMMDD");
CLEAR W523_IMPORTFILE_ATTR_XMLNS, W523_IMPORTFILE_ATTR_TEMPLATE, W523_IMPORTFILE_ATTR_DATEFMT;
//
XML_OP INSERT TRADEIMPORT;
//
W523_TRADEIMPORT_ATTR_TYPE = DOMNODESETATTRIBUTE(TRADEIMPORT , "type" , "test");
CLEAR W523_TRADEIMPORT_ATTR_TYPE;
//
XML_OP INSERT ZAINETKEY;
ZAINETKEY.NODEVALUE = "test";
//
//
TRADEIMPORT_FILE = DOMDOCSAVEFILE(IMPORTFILE , "testxmlns.xml");


This is the output in testxmlns.xml:

<?xml version="1.0" encoding="UTF-8"?>
<importFile xmlns="http://DealImporter/Importer" template="Default" dateFmt="YYYYMMDD"><tradeImport xmlns="" type="test"><zkey>test</zkey></tradeImport></importFile>


=> <tradeImport> also has the attribute.

There is another way of adding xml attributes, eg
IMPORTFILE.xmlns = "xxx".
With this solution, the attribute is added in all CAPS (<importFile XMLNS="xxx">).

Solution

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms