You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Frank Zhou <fc...@yahoo.com> on 2006/09/12 22:01:55 UTC

valid schema can not be loaded using Xerces 2.7

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 tried to loadGrammar using schema a like this:

    SAXParser*		parser = new SAXParser;
    actaHandlers*	handler = new actaHandlers(); 

    parser->setValidationScheme(SAXParser::Val_Never);
    parser->setDoNamespaces(true);
    parser->setDoSchema(true);

    parser->setErrorHandler(handler);
//  parser->setEntityResolver(handler);
    parser->setDocumentHandler(handler);

    try
    {
	parser->loadGrammar(input,
Grammar::SchemaGrammarType);
}
    catch (const XMLException& e)
    {
          ......
    }
  
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.

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 

RE: valid schema can not be loaded using Xerces 2.7

Posted by Alberto Massari <am...@datadirect.com>.
At 10.50 15/09/2006 -0700, Xiaofan Zhou wrote:
>Hi Alberto,
>
>Thanks very much. But my dilemma is that a.xsd (or d.xsd in your
>proposed solution) is trying to use something in b.xsd, and b.xsd is
>trying to use something in c.xsd, so I have this nested <import>ing
>thing. I guess I will have to change this in the schemas in order to use
>Xerces.

I am not sure my approach will work (as I haven't tested it) but when 
b.xsd will try to load c.xsd the entity resolver will handle the 
entire d.xsd that includes c.xsd.

Alberto


>Thanks again.
>Frank
>
>-----Original Message-----
>From: Alberto Massari [mailto:amassari@datadirect.com]
>Sent: Friday, September 15, 2006 1:38 AM
>To: c-dev@xerces.apache.org
>Subject: RE: valid schema can not be loaded using Xerces 2.7
>
>Hi Frank,
>
>At 09.24 14/09/2006 -0700, Frank Zhou wrote:
> >Hi Alberto,
> >
> >Thanks for the explanation. So what are the best wordarounds then?
> >Although modifying the schemas really not an option for me (I got the
> >issue from one of my biggest customer, and they have standardize their
> >schemas this way, also seems like all other tools like XMLSpy can load
> >their schemas), I still would like to explore them. It seems to me that
>
> >I don't have a solution here, because in my real user case, a.xsd will
> >use some types in b.xsd, and b.xsd will use some types in c.xsd, so
> >even if I have a.xsd including c.xsd, I still can not let a.xsd import
> >b.xsd, and b.xsd import a.xsd (instead of c.xsd), this won't work
> >either, right?
> >
> >As a workaround, is it possible that I just change the Xerces code to
> >keep loading the grammar even if it is found in the pool? I mean, in
> >preprocessImport in traverseSchema.cpp, remove the lines if
> >(grammarFound) return;
>
>No, or you will get an infinite loop if you load a.xsd that imports
>b.xsd that imports a.xsd.
>An approach you could try is creating d.xsd like this
>
><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">
>    <xs:include schemaLocation="c.xsd"/>
>    <xs:include schemaLocation="a.xsd"/>
></xs:schema>
>
>and then register an entity resolver that provides this schema file
>whenever resolveEntity is invoked with the namespace
>http://www.xyz.org/XYZ and the flag XMLResourceIdentifier::SchemaImport.
>
>Hope this helps,
>Alberto
>
>
> >Thanks.
> >Frank
> >
> >
> >
> >
> >--- Alberto Massari <am...@datadirect.com> wrote:
> >
> > > 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:amassari@datadirect.com]
> > > >Sent: Wednesday, September 13, 2006 12:53 AM
> > > >To: c-dev@xerces.apache.org
> > > >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:
> > > c-dev-unsubscribe@xerces.apache.org
> > > > >For additional commands, e-mail:
> > > c-dev-help@xerces.apache.org
> > > >
> > >
> >=== message truncated ===
> >
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Tired of spam?  Yahoo! Mail has the best spam protection around
> >http://mail.yahoo.com
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
> >For additional commands, e-mail: c-dev-help@xerces.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
>For additional commands, e-mail: c-dev-help@xerces.apache.org
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
>For additional commands, e-mail: c-dev-help@xerces.apache.org


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


RE: valid schema can not be loaded using Xerces 2.7

Posted by Xiaofan Zhou <Xi...@businessobjects.com>.
Hi Alberto,

Thanks very much. But my dilemma is that a.xsd (or d.xsd in your
proposed solution) is trying to use something in b.xsd, and b.xsd is
trying to use something in c.xsd, so I have this nested <import>ing
thing. I guess I will have to change this in the schemas in order to use
Xerces.

Thanks again.
Frank

-----Original Message-----
From: Alberto Massari [mailto:amassari@datadirect.com] 
Sent: Friday, September 15, 2006 1:38 AM
To: c-dev@xerces.apache.org
Subject: RE: valid schema can not be loaded using Xerces 2.7

Hi Frank,

At 09.24 14/09/2006 -0700, Frank Zhou wrote:
>Hi Alberto,
>
>Thanks for the explanation. So what are the best wordarounds then? 
>Although modifying the schemas really not an option for me (I got the 
>issue from one of my biggest customer, and they have standardize their 
>schemas this way, also seems like all other tools like XMLSpy can load 
>their schemas), I still would like to explore them. It seems to me that

>I don't have a solution here, because in my real user case, a.xsd will 
>use some types in b.xsd, and b.xsd will use some types in c.xsd, so 
>even if I have a.xsd including c.xsd, I still can not let a.xsd import 
>b.xsd, and b.xsd import a.xsd (instead of c.xsd), this won't work 
>either, right?
>
>As a workaround, is it possible that I just change the Xerces code to 
>keep loading the grammar even if it is found in the pool? I mean, in 
>preprocessImport in traverseSchema.cpp, remove the lines if 
>(grammarFound) return;

No, or you will get an infinite loop if you load a.xsd that imports
b.xsd that imports a.xsd.
An approach you could try is creating d.xsd like this

<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">
   <xs:include schemaLocation="c.xsd"/>
   <xs:include schemaLocation="a.xsd"/>
</xs:schema>

and then register an entity resolver that provides this schema file
whenever resolveEntity is invoked with the namespace
http://www.xyz.org/XYZ and the flag XMLResourceIdentifier::SchemaImport.

Hope this helps,
Alberto


>Thanks.
>Frank
>
>
>
>
>--- Alberto Massari <am...@datadirect.com> wrote:
>
> > 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:amassari@datadirect.com]
> > >Sent: Wednesday, September 13, 2006 12:53 AM
> > >To: c-dev@xerces.apache.org
> > >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:
> > c-dev-unsubscribe@xerces.apache.org
> > > >For additional commands, e-mail:
> > c-dev-help@xerces.apache.org
> > >
> >
>=== message truncated ===
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around
>http://mail.yahoo.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
>For additional commands, e-mail: c-dev-help@xerces.apache.org


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

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


RE: valid schema can not be loaded using Xerces 2.7

Posted by Alberto Massari <am...@datadirect.com>.
Hi Frank,

At 09.24 14/09/2006 -0700, Frank Zhou wrote:
>Hi Alberto,
>
>Thanks for the explanation. So what are the best
>wordarounds then? Although modifying the schemas
>really not an option for me (I got the issue from one
>of my biggest customer, and they have standardize
>their schemas this way, also seems like all other
>tools like XMLSpy can load their schemas), I still
>would like to explore them. It seems to me that I
>don't have a solution here, because in my real user
>case, a.xsd will use some types in b.xsd, and b.xsd
>will use some types in c.xsd, so even if I have a.xsd
>including c.xsd, I still can not let a.xsd import
>b.xsd, and b.xsd import a.xsd (instead of c.xsd), this
>won't work either, right?
>
>As a workaround, is it possible that I just change the
>Xerces code to keep loading the grammar even if it is
>found in the pool? I mean, in preprocessImport in
>traverseSchema.cpp, remove the lines if (grammarFound)
>return;

No, or you will get an infinite loop if you load a.xsd that imports 
b.xsd that imports a.xsd.
An approach you could try is creating d.xsd like this

<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">
   <xs:include schemaLocation="c.xsd"/>
   <xs:include schemaLocation="a.xsd"/>
</xs:schema>

and then register an entity resolver that provides this schema file 
whenever resolveEntity is invoked with the namespace 
http://www.xyz.org/XYZ and the flag XMLResourceIdentifier::SchemaImport.

Hope this helps,
Alberto


>Thanks.
>Frank
>
>
>
>
>--- Alberto Massari <am...@datadirect.com> wrote:
>
> > 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:amassari@datadirect.com]
> > >Sent: Wednesday, September 13, 2006 12:53 AM
> > >To: c-dev@xerces.apache.org
> > >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:
> > c-dev-unsubscribe@xerces.apache.org
> > > >For additional commands, e-mail:
> > c-dev-help@xerces.apache.org
> > >
> >
>=== message truncated ===
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around
>http://mail.yahoo.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
>For additional commands, e-mail: c-dev-help@xerces.apache.org


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


Re: valid schema can not be loaded using Xerces 2.7

Posted by Axel Weiß <aw...@informatik.hu-berlin.de>.
Frank Zhou wrote:
> Hi Alberto,
>
> Thanks for the explanation. So what are the best
> wordarounds then? Although modifying the schemas
> really not an option for me (I got the issue from one
> of my biggest customer, and they have standardize
> their schemas this way, also seems like all other
> tools like XMLSpy can load their schemas), I still
> would like to explore them. It seems to me that I
> don't have a solution here, because in my real user
> case, a.xsd will use some types in b.xsd, and b.xsd
> will use some types in c.xsd, so even if I have a.xsd
> including c.xsd, I still can not let a.xsd import
> b.xsd, and b.xsd import a.xsd (instead of c.xsd), this
> won't work either, right?
>
> As a workaround, is it possible that I just change the
> Xerces code to keep loading the grammar even if it is
> found in the pool? I mean, in preprocessImport in
> traverseSchema.cpp, remove the lines if (grammarFound)
> return;

In a.xsd, you could <include> c.xsd.

What I understand is that you want to realize a multi-author system for 
extending a base namespace. On toplevel, a.xsd describes a framework and 
c.xsd offers some base types. Now some random b.xsd define specialized types 
that are part of the framework (a.xsd imports them), and they all use the 
base types in c.xsd. Since a.xsd and c.xsd share the same namespace, a.xsd 
(the root schema) should include it and play the role of the unique namespace 
url.

HTH (if you happen to get this working with xerces - can you post some neat 
examples in the xerces-user ML :)

			Axel

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


RE: valid schema can not be loaded using Xerces 2.7

Posted by Frank Zhou <fc...@yahoo.com>.
Hi Alberto,

Thanks for the explanation. So what are the best
wordarounds then? Although modifying the schemas
really not an option for me (I got the issue from one
of my biggest customer, and they have standardize
their schemas this way, also seems like all other
tools like XMLSpy can load their schemas), I still
would like to explore them. It seems to me that I
don't have a solution here, because in my real user
case, a.xsd will use some types in b.xsd, and b.xsd
will use some types in c.xsd, so even if I have a.xsd
including c.xsd, I still can not let a.xsd import
b.xsd, and b.xsd import a.xsd (instead of c.xsd), this
won't work either, right?

As a workaround, is it possible that I just change the
Xerces code to keep loading the grammar even if it is
found in the pool? I mean, in preprocessImport in
traverseSchema.cpp, remove the lines if (grammarFound)
return;

Thanks.
Frank




--- Alberto Massari <am...@datadirect.com> wrote:

> 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:amassari@datadirect.com]
> >Sent: Wednesday, September 13, 2006 12:53 AM
> >To: c-dev@xerces.apache.org
> >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:
> c-dev-unsubscribe@xerces.apache.org
> > >For additional commands, e-mail:
> c-dev-help@xerces.apache.org
> >
> 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


RE: valid schema can not be loaded using Xerces 2.7

Posted by Alberto Massari <am...@datadirect.com>.
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:amassari@datadirect.com]
>Sent: Wednesday, September 13, 2006 12:53 AM
>To: c-dev@xerces.apache.org
>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: c-dev-unsubscribe@xerces.apache.org
> >For additional commands, e-mail: c-dev-help@xerces.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
>For additional commands, e-mail: c-dev-help@xerces.apache.org
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
>For additional commands, e-mail: c-dev-help@xerces.apache.org


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


RE: valid schema can not be loaded using Xerces 2.7

Posted by Xiaofan Zhou <Xi...@businessobjects.com>.
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:amassari@datadirect.com] 
Sent: Wednesday, September 13, 2006 12:53 AM
To: c-dev@xerces.apache.org
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: c-dev-unsubscribe@xerces.apache.org
>For additional commands, e-mail: c-dev-help@xerces.apache.org


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

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


Re: valid schema can not be loaded using Xerces 2.7

Posted by Alberto Massari <am...@datadirect.com>.
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: c-dev-unsubscribe@xerces.apache.org
>For additional commands, e-mail: c-dev-help@xerces.apache.org


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