[xsd-users] cxx-parser: run time difficulties with KML21.xsd

David White dawhite32 at gmail.com
Sun May 30 10:41:25 EDT 2010


Hi all,

As the subject suggests, I am having some difficulty with basic run-time usage of cxx-parser generated code and KML and would greatly value your suggestions as to where I am going wrong.

I downloaded the kml 2.1 schema from here: http://code.google.com/apis/kml/schema/kml21.xsd

Using cxx-parser, I ran:

xsd cxx-parser --generate-print-impl --force-overwrite --generate-test-driver --generate-polymorphic --root-element kml --namespace-map http://earth.google.com/kml/2.1=kml kml21.xsd

All generated c++ files compiled without errors.

However, when I run any KML file (using the generated kml21-driver.cxx), I get  error: Unknown element 'kml'

I note that kml files have for the (root) kml element the following:

[sample.kml]
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.1">
   <Place mark>
   ...
   </Place mark>
   ...
</kml>

I have read different threads on similar problems (e.g. http://www.codesynthesis.com/pipermail/xsd-users/2007-June/001018.html) and note that this error is raised when the parser does not have or know the full path to the schema.

My preference is to not disable the underlying parser, and so I added the following:
<kml xmlns:xsi="http://www.opengis.net/kml/2.1" xsi:noNamespaceSchemaLocation="kml21.xsd">

kml21.xsd is in the same directory as sample.kml.  But this didn't seem to work (I am not an XML expert).

I added xml_schema::flags::dont_validate to the parse function call, however I got the following error: expected element 'http://earth.google.com/kml/2.1#kml' instead of 'kml'

Any ideas where I am going wrong?  Please forgive me if the error is blatantly obvious.

OS:   FC12, gcc.
XSD:  3.2.0

Thanks in advance, David.




More information about the xsd-users mailing list