[xsd-users] No declaration found for element 'people'

Boris Kolpackov boris at codesynthesis.com
Fri Feb 13 13:41:25 EST 2009


Hi Anatoly,

Anatoly Borodyansky <aborodya at yahoo.com> writes:

> I'm trying to use parser version of the product, and when I build auto- 
> generated example based on the people XML example in the users  
> guide(pp 8-9 of cxx-parser-guide.PDF), parsing fails with the message  
> above. There is no ppl namespace, or target namespace specified in  
> this example, so XML looks like
>
> <people>
> ...
> </people>
>
> Is there a way to make it work without altering the XML file?

The reason you get this error is because the underlying XML parser
(Xerces-C++) cannot find the schema to validate the document against.
There are several ways to fix this without modifying the XML document:

1. You can disable XML Schema validation by passing the dont_validate
   flag to the parse() function. See Section 7.1, "Xerces-C++ Document
   Parser" for details.

2. You can disable XML Schema validation in the underlying XML parser
   as per (1) but enable it in the generating code by compiling your
   schemas with --generate-validation option. See Section 5.3, "XML
   Schema Validation" for details.

3. If you would like to use XML Schema validation in the underlying
   parser, then there are several methods to locate the schemas other
   that specifying them inside the document with schemaLocation and
   noNamespaceSchemaLocation attributes. The easiest way would be use
   the properties argument to the parse() function as described in the
   above-mentioned Section 7.1. It is also possible to pre-load the
   schemas in to the XML parser object and use that to parse several
   documents. This way the schemas will be loaded and parsed only
   once. For this methos you will need to use one of the parse()
   functions that take the SAX2XMLReader object which you will need
   to create and load the schemas into.

Boris




More information about the xsd-users mailing list