[xsd-users] Can't parse root element with xmlns attribute.

Erasmo Aguilera eaguilerai at hotmail.com
Fri Nov 15 15:30:23 EST 2013


Hi,

I barely modified the hello example from the
<http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/>
C++/Parser Mapping Getting Started Guide is such a way that it uses
namespaces.

The XML Schema (hello.xsd):

<?xml version="1.0"?>

<xs:schema 

  xmlns:xs="http://www.w3.org/2001/XMLSchema"

  targetNamespace="http://www.mysite.com/hello"

  xmlns="http://www.mysite.com/hello"

  elementFormDefault="qualified">

 

  <xs:complexType name="hello">

...

The XML instance document (hello.xml):

<?xml version="1.0"?>

<hello xmlns="http://www.mysite.com/hello" 

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xsi:schemaLocation="http://www.mysite.com/hello hello.xsd">

...

The XSD compilation command:

xsd cxx-parser^

--xml-parser xerces^

--output-dir parser\^

--force-overwrite^

--hxx-suffix .h^

--cxx-suffix .cpp^

--generate-print-impl^

--generate-test-driver^

--generate-validation^

--skel-type-suffix "-pskel"^

--skel-file-suffix "-pskel"^

--impl-type-suffix "-pimpl"^

--impl-file-suffix "-pimpl"^

hello.xsd

The output files compile correctly on Visual Studio 2012. The problem comes
at the execution when using hello.xml:

.../hello.xml:4:67 error: unexpected attribute 'xmlns'

I supposed that was because the xmlns attribute wasn't defined for the hello
element in the XML Schema, but as you know, you can't define an attribute
with such a name.

Thanks for your help.

Erasmo.



More information about the xsd-users mailing list