xerces-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Glavassevich <mrgla...@ca.ibm.com>
Subject Re: XSModel - namespaces for imported schema
Date Thu, 27 Aug 2009 12:09:02 GMT

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


Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Mark Brucks <brux54@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
View raw message