You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Lisa Bahler <ba...@research.telcordia.com> on 2005/12/02 22:15:22 UTC

Multiple schema imports not handled

I am using Xerces 2.7.1.

A schema associated with one namespace is trying to import multiple 
schemas that are each associated with another namespace.  Only the first 
in a sequence of imports appears to be processed.  (The same thing 
happens if the sequence contains both includes and imports; the first 
such element, whether an import or include, is the only one that appears 
to be processed.)

When types from the schemas associated with all but the first import or 
include are encountered in the top level schema, I see a lot of 
unresolved references.

A sequence of includes works properly, by the way.  The issue is 
encountered only if imports are involved.

I created a simplified version of what I am seeing.  I have 3 schemas, 
all in the same directory.

Top.xsd:

> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
> targetNamespace="topLevelNS" elementFormDefault="qualified" 
> attributeFormDefault="unqualified" xmlns="topLevelNS"
> xmlns:b = "bottomLevelNS">
>     <xs:import namespace="bottomLevelNS" schemaLocation="A.xsd"/>
>     <xs:import namespace="bottomLevelNS" schemaLocation="B.xsd"/>
>
>     <xs:element name="root">
>         <xs:complexType>
>             <xs:sequence>
>                 <xs:element name="A" type="b:AType"/>
>                 <xs:element name="B" type="b:BType"/>
>             </xs:sequence>
>         </xs:complexType>
>     </xs:element>
> </xs:schema>


A.xsd:

> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
> targetNamespace="bottomLevelNS" elementFormDefault="qualified" 
> attributeFormDefault="unqualified" xmlns="bottomLevelNS">
>     <xs:simpleType name="AType">
>         <xs:restriction base="xs:string"/>
>     </xs:simpleType>
> </xs:schema>

B.xsd:

> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
> targetNamespace="bottomLevelNS" elementFormDefault="qualified" 
> attributeFormDefault="unqualified" xmlns="bottomLevelNS">
>     <xs:simpleType name="BType">
>         <xs:restriction base="xs:string"/>
>     </xs:simpleType>
> </xs:schema>

When I validate Top.xsd, I see:

> ERROR  - Line 11 [42] {Top.xsd}: src-resolve: Cannot resolve the name 
> 'b:BType' to a(n) 'type definition' component.


When I change the order of the imports, I see that b:AType is not 
resolved instead.

I am obviously not understanding something here, since I believe that 
Top.xsd is valid.  Would someone please help me?

Thanks,
Lisa


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Multiple schema imports not handled

Posted by Lisa Bahler <ba...@research.telcordia.com>.
Michael,

Thanks.  We had been using an older Xerces version, and before I sent my 
query, I tried our code with the latest version to see if that made a 
difference.  I was not aware of this new feature that was added with 
2.7, however, so I did not set that in my code.

Lisa


Michael Glavassevich wrote:

>Hi Lisa,
>
>Since the schemaLocation attribute is only a hint, schema processors are 
>allowed to ignore all but the first import for a given namespace. This is 
>what Xerces-J does by default. To instruct the parser to read from all the 
>schema locations specified for a given namespace you need to set the 
>honour-all-schemaLocations [1] feature to true.
>
>Thanks.
>
>[1] 
>http://xerces.apache.org/xerces2-j/features.html#honour-all-schemaLocations
>
>Michael Glavassevich
>XML Parser Development
>IBM Toronto Lab
>E-mail: mrglavas@ca.ibm.com
>E-mail: mrglavas@apache.org
>
>Lisa Bahler <ba...@research.telcordia.com> wrote on 12/02/2005 04:15:22 
>PM:
>
>  
>
>>I am using Xerces 2.7.1.
>>
>>A schema associated with one namespace is trying to import multiple 
>>schemas that are each associated with another namespace.  Only the first 
>>    
>>
>
>  
>
>>in a sequence of imports appears to be processed.  (The same thing 
>>happens if the sequence contains both includes and imports; the first 
>>such element, whether an import or include, is the only one that appears 
>>    
>>
>
>  
>
>>to be processed.)
>>
>>When types from the schemas associated with all but the first import or 
>>include are encountered in the top level schema, I see a lot of 
>>unresolved references.
>>
>>A sequence of includes works properly, by the way.  The issue is 
>>encountered only if imports are involved.
>>
>>I created a simplified version of what I am seeing.  I have 3 schemas, 
>>all in the same directory.
>>
>>Top.xsd:
>>
>>    
>>
>>><?xml version="1.0" encoding="UTF-8"?>
>>><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
>>>targetNamespace="topLevelNS" elementFormDefault="qualified" 
>>>attributeFormDefault="unqualified" xmlns="topLevelNS"
>>>xmlns:b = "bottomLevelNS">
>>>    <xs:import namespace="bottomLevelNS" schemaLocation="A.xsd"/>
>>>    <xs:import namespace="bottomLevelNS" schemaLocation="B.xsd"/>
>>>
>>>    <xs:element name="root">
>>>        <xs:complexType>
>>>            <xs:sequence>
>>>                <xs:element name="A" type="b:AType"/>
>>>                <xs:element name="B" type="b:BType"/>
>>>            </xs:sequence>
>>>        </xs:complexType>
>>>    </xs:element>
>>></xs:schema>
>>>      
>>>
>>A.xsd:
>>
>>    
>>
>>><?xml version="1.0" encoding="UTF-8"?>
>>><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
>>>targetNamespace="bottomLevelNS" elementFormDefault="qualified" 
>>>attributeFormDefault="unqualified" xmlns="bottomLevelNS">
>>>    <xs:simpleType name="AType">
>>>        <xs:restriction base="xs:string"/>
>>>    </xs:simpleType>
>>></xs:schema>
>>>      
>>>
>>B.xsd:
>>
>>    
>>
>>><?xml version="1.0" encoding="UTF-8"?>
>>><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
>>>targetNamespace="bottomLevelNS" elementFormDefault="qualified" 
>>>attributeFormDefault="unqualified" xmlns="bottomLevelNS">
>>>    <xs:simpleType name="BType">
>>>        <xs:restriction base="xs:string"/>
>>>    </xs:simpleType>
>>></xs:schema>
>>>      
>>>
>>When I validate Top.xsd, I see:
>>
>>    
>>
>>>ERROR  - Line 11 [42] {Top.xsd}: src-resolve: Cannot resolve the name 
>>>'b:BType' to a(n) 'type definition' component.
>>>      
>>>
>>When I change the order of the imports, I see that b:AType is not 
>>resolved instead.
>>
>>I am obviously not understanding something here, since I believe that 
>>Top.xsd is valid.  Would someone please help me?
>>
>>Thanks,
>>Lisa
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
>>For additional commands, e-mail: j-users-help@xerces.apache.org
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
>For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Multiple schema imports not handled

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Lisa,

Since the schemaLocation attribute is only a hint, schema processors are 
allowed to ignore all but the first import for a given namespace. This is 
what Xerces-J does by default. To instruct the parser to read from all the 
schema locations specified for a given namespace you need to set the 
honour-all-schemaLocations [1] feature to true.

Thanks.

[1] 
http://xerces.apache.org/xerces2-j/features.html#honour-all-schemaLocations

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

Lisa Bahler <ba...@research.telcordia.com> wrote on 12/02/2005 04:15:22 
PM:

> I am using Xerces 2.7.1.
> 
> A schema associated with one namespace is trying to import multiple 
> schemas that are each associated with another namespace.  Only the first 

> in a sequence of imports appears to be processed.  (The same thing 
> happens if the sequence contains both includes and imports; the first 
> such element, whether an import or include, is the only one that appears 

> to be processed.)
> 
> When types from the schemas associated with all but the first import or 
> include are encountered in the top level schema, I see a lot of 
> unresolved references.
> 
> A sequence of includes works properly, by the way.  The issue is 
> encountered only if imports are involved.
> 
> I created a simplified version of what I am seeing.  I have 3 schemas, 
> all in the same directory.
> 
> Top.xsd:
> 
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
> > targetNamespace="topLevelNS" elementFormDefault="qualified" 
> > attributeFormDefault="unqualified" xmlns="topLevelNS"
> > xmlns:b = "bottomLevelNS">
> >     <xs:import namespace="bottomLevelNS" schemaLocation="A.xsd"/>
> >     <xs:import namespace="bottomLevelNS" schemaLocation="B.xsd"/>
> >
> >     <xs:element name="root">
> >         <xs:complexType>
> >             <xs:sequence>
> >                 <xs:element name="A" type="b:AType"/>
> >                 <xs:element name="B" type="b:BType"/>
> >             </xs:sequence>
> >         </xs:complexType>
> >     </xs:element>
> > </xs:schema>
> 
> 
> A.xsd:
> 
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
> > targetNamespace="bottomLevelNS" elementFormDefault="qualified" 
> > attributeFormDefault="unqualified" xmlns="bottomLevelNS">
> >     <xs:simpleType name="AType">
> >         <xs:restriction base="xs:string"/>
> >     </xs:simpleType>
> > </xs:schema>
> 
> B.xsd:
> 
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
> > targetNamespace="bottomLevelNS" elementFormDefault="qualified" 
> > attributeFormDefault="unqualified" xmlns="bottomLevelNS">
> >     <xs:simpleType name="BType">
> >         <xs:restriction base="xs:string"/>
> >     </xs:simpleType>
> > </xs:schema>
> 
> When I validate Top.xsd, I see:
> 
> > ERROR  - Line 11 [42] {Top.xsd}: src-resolve: Cannot resolve the name 
> > 'b:BType' to a(n) 'type definition' component.
> 
> 
> When I change the order of the imports, I see that b:AType is not 
> resolved instead.
> 
> I am obviously not understanding something here, since I believe that 
> Top.xsd is valid.  Would someone please help me?
> 
> Thanks,
> Lisa
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org