Michael:
Thanks for the response. I assumed that xs:anyType and a content type
of mixed was the "most general" substitution if it couldn't find the
schema. However, I am using an entity resolver. Here is how I
created and configured my grammar preparser:
grammarParser = new XMLGrammarPreparser();
grammarParser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
grammarParser.setFeature(Constants.XERCES_FEATURE_PREFIX +
Constants.NAMESPACE_PREFIXES_FEATURE, true);
grammarParser.setFeature(Constants.NAMESPACES_FEATURE, true);
grammarParser.setFeature(Constants.SCHEMA_AUGMENT_PSVI, true);
grammarParser.setFeature(Constants.SCHEMA_ELEMENT_DEFAULT,
true);
grammarParser.setFeature(Constants.SCHEMA_FULL_CHECKING, true);
grammarParser.setFeature(Constants.SCHEMA_NORMALIZED_VALUE,
true);
grammarParser.setFeature(Constants.SCHEMA_VALIDATION_FEATURE,
true);
grammarParser.setFeature(Constants.VALIDATION_FEATURE, true);
String grammarPoolProperty0 =
Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
grammarParser.setProperty(grammarPoolProperty0,
catalogResolver);
String grammarPoolProperty = Constants.XERCES_PROPERTY_PREFIX
+ Constants.XMLGRAMMAR_POOL_PROPERTY;
grammarParser.setProperty(grammarPoolProperty, new
XMLGrammarPoolImpl());
I checked my catalog resolver and was pretty sure that was right. I
was still worried that I had done something wrong, so I added the
location of the second schema to the first, using the following:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.grs.com/WayptSchema ./
waypt.xsd"
The mission and waypt schemata are in the same directory, and I tried
it with both relative and absolute paths. Still the same problem. Is
it possibly something wrong with my configuration of the grammar
preparser?
Mark
On Aug 27, 2009, at 5:09 AM, Michael Glavassevich wrote:
Hi Mark,
There's an error message that you're probably ignoring which would
be complaining about not being able to resolve "wp:WayptType". When
a type definition cannot be found Xerces recovers from this error by
assigning xs:anyType as the type of the element. You do have an
import in the first schema document but it has no schema location
hint (e.g. schemaLocation="file:///some/uri). Therefore the schema
loader would have no idea where to find the other schema document
unless you register an entity resolver that knows how to locate it
based on the namespace "http://www.grs.com/WayptSchema".
Thanks.
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrgla...@ca.ibm.com
E-mail: mrgla...@apache.org
Mark Brucks <bru...@charter.net> wrote on 08/26/2009 05:50:36 PM:
> I'm parsing a schema and traversing the resultant XSModel instance.
> I'm having problems getting the correct content types and namespace
> information for elements whose types are declared in an imported
schema.
>
> I have two schemata, the first imports the second. A relevant
> snippet of the first is:
>
> <xs:schema targetNamespace="http://www.grs.com/MissionSchema"
> xmlns:mis ="http://www.grs.com/MissionSchema"
> xmlns:wp ="http://www.grs.com/WayptSchema"
> xmlns:xs ="http://www.w3.org/2001/XMLSchema"
> elementFormDefault ="qualified"
> attributeFormDefault ="unqualified">
>
> <xs:import namespace="http://www.grs.com/WayptSchema"/>
>
> <xs:element name="mission">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="waypt_defs">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="waypt" type="wp:WayptType"
maxOccurs=
> "unbounded"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> ...
>
> and a relevant snippet of the second is:
>
> <xs:schema targetNamespace="http://www.grs.com/WayptSchema"
> xmlns:wp ="http://www.grs.com/WayptSchema"
> xmlns:xs ="http://www.w3.org/2001/XMLSchema"
> elementFormDefault ="qualified"
> attributeFormDefault ="unqualified">
>
> <xs:complexType name="WayptType">
> <xs:sequence>
> <xs:element name="location">
> <xs:complexType>
> <xs:attribute name="lat" type="xs:double"/>
> <xs:attribute name="lon" type="xs:double"/>
> ...
>
> After I parse the first schema I traverse the XSModel. When I reach
> the XSElementDeclaration for the element “waypt”, I get a content
> type I don't understand. The XSTypeDefinition is
> XSComplexTypeDefinition, which is good. However, the content type
> is CONTENTTYPE_MIXED, the name is “anyType” and the namespace is
> http://www.w3.org/2001/XMLSchema. It would seem that it isn't
> recognizing the imported schema. I printed out the schema namespaces
> (returned from XSModel.getNamespaces()), and sure enough, the waypt
> schema isn't printed.
>
> I'm missing something fundamental here - what is it?
>
> Thanks - Mark