XMLNS
Hi there,
my task is to generate a GSDML - File for an Profinet - IO Device.
have to code it with C++ and DOM.
Valid XML - File is by ex.:
<?xml version="1.0" encoding="iso-8859-1"?>
<ISO15745Profile xmlns="http://www.profibus.com/GSDML/2003/11/DeviceProfile"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.profibus.com/GSDML/2003/11/DeviceProfile ..\XSD\GSDML-DeviceProfile-v2.0.xsd">
<ProfileHeader>
<ProfileIdentification>PROFINET Device Profile</ProfileIdentification>
<...
If i try to create the Namespace as usual in GSDML (<ISO15745Profile xmlns="http://www.profibus.com/GSDML/2003/11/DeviceProfile" xmlns:xsi="http://www ... etc), the next Element Definition
(<ProfileHeader>) is passed with the requestment of an additional Namespace (<ProfileHeader xmlns="">).
Could anybody help me with my coding ?
current code is:
hResult = spDocOutput.CreateInstance(__uuidof(DOMDocument40) );
// Create the XML Declaration as a Processing Instruction
// and append it to the document node
spXMLDecl = spDocOutput->createProcessingInstruction("xml","version=\"1.0\ " encoding=\"iso-8859-1\"");
spDocOutput->appendChild(spXMLDecl);
// Create the root element and append it to the Document
_variant_t varNodeType((short)MSXML2::NODE_ELEMENT);
spElemRoot = spDocOutput->createNode(varNodeType, "ISO15745Profile", "");
spDocOutput->appendChild(spElemRoot);
// This is the problem, when the line is inserted, the first Node is changed to xmlns=""
spElemRoot->setAttribute("xmlns", "http://www.profibus.com/GSDML/2003/11/DeviceProfile");
spElemRoot->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
spElemRoot->setAttribute("xsi:schemaLocation",
"http://www.profibus.com/GSDML/2003/11/DeviceProfile ..\\XSD\\GSDML-DeviceProfile-v2.0.xsd");
Current output is :
<ISO15745Profile xmlns="http://www.profibus.com/GSDML/2003/11/DeviceProfile"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.profibus.com/GSDML/2003/11/DeviceProfile ..\XSD\GSDML-DeviceProfile-v2.0.xsd">
<ProfileHeader xmlns="">
<ProfileIdentification>PROFINET ....
many thanks in advance!
|