[xsd-users] Re: Substitution groups & different namespaces.

Boris Kolpackov boris at codesynthesis.com
Thu Dec 14 03:50:52 EST 2006


Hi David,

Moss, David R (SELEX Comms) (UK Christchurch) <david.r.moss at selex-comm.com> writes:

> an exception is thrown stating:
>
> "There is no Grammar for uri: ."
>
> I'm thinking it has something to do with the derived xsi:type specified
> in the XML file being in a different (i.e. not in one at all) namespace
> to the Base types.

Here is what happens: (1) you have XML Schema validation enabled in the
underlying parser and (2) you specify a type in xsi:type attribute for
which there is no schema can be found. Here are the number of ways in
which you can address this:

1. Specify the schema where the type is defined with, in your case, the
   xsi:noNamespaceSchemaLocation attribute:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<b:UserDatabase  xmlns:b="http://www.dave.com/Base"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:type="DerivedUserConfig_t"
                 xsi:schemaLocation="http://www.dave.com/Base test-users.xsd"
		 xsi:noNamespaceSchemaLocation="derived-user-config.xsd">

</b:UserDatabase>


  With this fix the parsing results in the following error, which makes
  sense:

  test-users.xml:7:60 error: Type 'DerivedUserConfig_t' that is used in
  xsi:type is not derived from the type of element 'UserDatabase'

  You can also use Xerces-C++ API for loading and caching schemas. Let
  me know if you would like more pointers on this.


2. Disable validation in the underlying parser with the
   xml_schema::flags::dont_validate flag:

   auto_ptr<Base::UserDatabase_t>
     db( Base::UserDatabase( "test-users.xml",
                             xml_schema::flags::dont_validate) );

3. Use "lax" validation in the underlying parser. Lax validation means
   that the instance will be validated only of the schema can be found.
   In your case that would mean that the XML instance will be validated
   while DerivedUserConfig_t won't. There is no XSD flag to request lax
   validation yet.


hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061214/a92f0b62/attachment.pgp


More information about the xsd-users mailing list