xerces-c-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dale Worley <dwor...@pingtel.com>
Subject Specifying the location of .xsd files to use when validating an XML file
Date Tue, 22 Jul 2008 18:49:38 GMT
This is another version of a question which seems to come up
perennially, but it seems to be slightly different than the versions I
can find discussion of.

I am using Xerces-C to validate an XML file.  The file uses a namespace,
but does not describe where to find the schema (.xsd file) for the
namespace.  So before validating the file, I call
fgXercesSchemaExternalSchemaLocation to give the names of the files
containing the schemas for the namespaces that the XML file might use.

So far, that works fine:  Xerces locates the schema for the namespace
that the XML file uses.

The difficulty is that one of the schemas imports another schema.
Xerces seems to demand that the first schema contain an <import>
element, and that the <import> provide the file name containing the
imported schema; the list provided to
fgXercesSchemaExternalSchemaLocation seems to have no effect.  Whereas I
would assume that the fgXercesSchemaExternalSchemaLocation list would be
consulted first to find the imported namespace, and the schemaLocation
attribute of the <import> element would be ignored.

In particular, section 4.2.3 of XML Schema Part 1 suggests that omitting
the schemaLocation attribute is intended to leave it to the processor to
determine how the find the schema, and in the context of Xerces, I would
expect Xerces to consult the fgXercesSchemaExternalSchemaLocation list.
But if I omit schemaLocation, I get errors like this:

Error at file file:///home/dworley/sandbox-151/dir-local/share/sipxecs/schema/alias.xsd, line
54, char 54
  Message: Schema Representation Constraint: Namespace 'http://www.sipfoundry.org/sipX/schema/xml/sip-00-01'
is referenced without <import> declaration

And note that the message is factually incorrect; there is an <import>



View raw message