Hi Frank,
the fact that you don't use <import> twice doesn't remove the constraint that there can only be one official location for each targetNamespace. In your case, both a.xsd and c.xsd have the same targetNamespace, and having both of them in the import chain will ignore one of the two.

Alberto

At 09.30 13/09/2006 -0700, Xiaofan Zhou wrote:
Alberto,

But in my case, I never "import" the same namespace more than once,
notice a.xsd and c.xsd have the same namespace but complete different
content, and b.xsd has a different namespace. Here is the sequence:

a.xsd (say has a namespace1)
   |-----import namespace2, location="b.xsd"
                         |--------------------import namespace1
location="c.xsd"

=====
Now when I loadGrammar like this:

Parser->loadGramma(inputSource(a), schemaGrammarType)

The Xerces logic seems like this (if I read correctly)

1)  the grammarPool has an item of namespace1, but really nothing there,
because we are just at the beginning of a.xsd
2)  processing import namespace2, as this is the first statement of
a.xsd
3)  processing import namespace1, as this is the first statement of
b.xsd
    Now when Xerces does this, it checks the grammarPool to see if
namespace1 is there, it found it and stop loading
    c.xsd.

This does not make sense to me.

Thanks.

Frank





-----Original Message-----
From: Alberto Massari [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 13, 2006 12:53 AM
To: [email protected]
Subject: Re: valid schema can not be loaded using Xerces 2.7

At 13.01 12/09/2006 -0700, Frank Zhou wrote:
>Hi All,
>
>I have the attached simple schemas a, b, and c, in which a import b,
>and b import c, a and c have the same target namespace, but b have a
>different target namespace.
>
>[...]
>I always get the type not found error for a type defined in schema.
>
>However, if I use schema b as the root, I don't have a problem. And I
>debugged the Xerces code, seems like in preprocessImport (in
>traverseSchema.cpp), when try to resolve schema c, because it have the
>same target namespace as a, and it thinks grammar already found, so
>stop loading types from schema c.

Hi Frank,
the behavior of Xerces is allowed by the specs; see the note in
$4.2.3 "Note: The above is carefully worded so that multiple <import>ing
of the same schema document will not constitute a violation of clause 2
of Schema Properties Correct ( 3.15.6), but applications are allowed,
indeed encouraged, to avoid <import>ing the same schema document more
than once to forestall the necessity of establishing identity component
by component. Given that the schemaLocation [attribute] is only a hint,
it is open to applications to ignore all but the first <import> for a
given namespace, regardless of the actual value of schemaLocation, but
such a strategy risks missing useful information when new
schemaLocations are offered."
So you should design your schemas to have a single .xsd as the official
repository for a given targetNamespace, and have it include all the
other pieces.

Hope this helps,
Alberto


>I tried to use my own entityResolver as well as the default one.
>
>Is this a bug in Xerces or I need to set up my parser differently?
>
>Thanks much.
>Frank
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around
>http://mail.yahoo.com <?xml version="1.0" encoding="UTF-8"?> <xs:schema

>xmlns="http://www.xyz.org/XYZ";
>xmlns:xs="http://www.w3.org/2001/XMLSchema";
>xmlns:ABC="http://www.xyz.org/ABC";
>targetNamespace="http://www.xyz.org/XYZ";
>elementFormDefault="qualified" attributeFormDefault="unqualified">
>         <xs:import namespace="http://www.xyz.org/ABC";
> schemaLocation="b.xsd"/>
>         <xs:element name="E1">
>             <xs:complexType>
>                <xs:sequence>
>                    <xs:element name="E3" type="e3Type"/>
>                </xs:sequence>
>            </xs:complexType>
>         </xs:element>
></xs:schema>
>
><?xml version="1.0" encoding="UTF-8"?>
><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
>xmlns:ABC="http://www.xyz.org/ABC";
>xmlns:XYZ="http://www.xyz.org/XYZ"; xmlns="http://www.xyz.org/ABC";
>targetNamespace="http://www.xyz.org/ABC";
>elementFormDefault="qualified" attributeFormDefault="unqualified">
>         <xs:import namespace="http://www.xyz.org/XYZ";
> schemaLocation="c.xsd"/>
>         <xs:element name="E2" type="XYZ:e2Type">
>         </xs:element>
></xs:schema>
>
><?xml version="1.0" encoding="utf-8"?>
><xs:schema xmlns="http://www.xyz.org/XYZ";
>xmlns:xs="http://www.w3.org/2001/XMLSchema";
>xmlns:ABC="http://www.xyz.org/ABC";
>targetNamespace="http://www.xyz.org/XYZ";
>elementFormDefault="qualified" attributeFormDefault="unqualified">
>         <xs:simpleType name="e2Type">
>                 <xs:restriction base="xs:int"/>
>         </xs:simpleType>
>         <xs:simpleType name="e3Type">
>                 <xs:restriction base="xs:string"/>
>         </xs:simpleType>
></xs:schema>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to