Wrox Programmer Forums
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 20th, 2007, 04:46 AM
Registered User
 
Join Date: Feb 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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!







Similar Threads
Thread Thread Starter Forum Replies Last Post
Omit xmlns Pankaj C XSLT 3 July 31st, 2007 10:18 AM
How do I get rid of xmlns= attributes? Peter Savas XSLT 6 July 11th, 2007 03:33 PM
xmlns albusr .NET Web Services 0 December 24th, 2005 08:25 AM
XPathExpression.AddSort not working with xmlns mokka°logic Pro VB.NET 2002/2003 0 September 10th, 2003 01:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.