Khaled, If I understood your strategy right, you are using the namespaceUri as a key to get a schema grammar. But why not use key as pair( namespaceUri, schemaId ) ? This uniquely identifies the schema to use as well as allows to prevent the circular imports.
Peter. ----- Original Message ----- From: "Khaled Noaman" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, October 17, 2002 11:18 PM Subject: Re: schemaLocation question > This is allowed. The schema spec says that the schemaLocation is only a > hint and it is open to application to ignore it for a given namespace if > that namespace was previously resolved. We chose to implement it that > way to eliminate the need for duplicate processing of the same namespace > and to prevent endless processing in the case of circular imports (i.e A > imports B which imports A). > > Khaled > > "Peter A. Volchek" wrote: > > > I have the question related to "schemaLocation" attribute > > processing.As I noticed in your code, when parser meeths the > > schemaLocation attribute with the uri that was already defined > > previously it just gets the schema grammar from cache and uses > > it. This causes the trouble when validating the following instance > > document: a.xml----------------------------------------------------------------------- ------<ns:A > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xmlns:ns="http://www.sample.com" > > xsi:schemaLocation="http://www.sample.com sch1.xsd"> > > > > <ns:B xsi:schemaLocation="http://www.sample.com > > sch2.xsd">Hello</ns:B> > > > > > > /ns:A>---------------------------------------------------------------------- ------- In > > this document the element A is declared in in schema sch1.xsd, and > > element B in sch2.xsdas > > follows: sch1.xsd-------------------------------------------------------------------- ---------<?xml > > version="1.0"?> > > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > > targetNamespace="http://www.sample.com"> <xs:element > > name="A"> > > <xs:complexType> > > <xs:sequence> > > <xs:any namespace="http://www.sample.com" minOccurs="1" > > maxOccurs="unbounded"/> > > </xs:sequence> > > </xs:complexType> > > > > </xs:element> </xs:schema>---------------------------------------------------------------- ------------- sch2.xsd-------------------------------------------------------------------- ---------<?xml > > version="1.0"?> > > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > > targetNamespace="http://www.sample.com"> <xs:element > > name="B" > > type="xs:string"/> </xs:schema>---------------------------------------------------------------- ------------- Now, > > if you parse with DOMPrint sample you'll get the following error: > > > DOMPrint.exe -v=always -n -s a.xmlError at file "a.xml", line 5, > > column 61 > > Message: Unknown element 'ns:B' THe reason is that parser ignores > > the second schemaLocation attribute, meaning that the grammar already > > exists for it in cache.Is this expected behaviour? What does XMLSchema > > rec. says about it ? Peter A. Volchek > > > --------------------------------------------------------------------- > 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]
