|
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.xsd
as 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
----------------------------------------------------------------------------- <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.xml
Error 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
|
- Re: schemaLocation question Peter A. Volchek
- Re: schemaLocation question Khaled Noaman
- Re: schemaLocation question Gareth Reakes
- Re: schemaLocation question Peter A. Volchek
- Re: schemaLocation question Khaled Noaman
