Re: Can schemas validate parts of an instance document?

Tom Gaven wrote:

> Can schemas be used to validate 'pieces' of an instance document?  For
> example, if I have the following instance document, which reference the 2
> schemas below, should I expect a schema validator  to validate (elements a
> and r), but leave mo, larry and curly alone?

Yes, I believe that a schema validator will validate what it can. In your
example the elements <a> and <r> will be validated since a schema validator
can find a schema for these elements. The other elements will not be
validated. Using XSV you would get the message "validation=lax" since strict
validation can't be used.
I'm not 100% certain so about this so please correct me if I'm wrong.

/Eddie

> instance document:
> <?xml version="1.0" ?>
> <mo xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
>    <larry>
>        <a xmlns="urn:TestA"
>           xsi:schemaLocation="urn:TestA testa.xsd" >
>           hello
>        </a>
>        <curly/>
>        <r xmlns="urn:TestR"
>           xsi:schemaLocation="urn:TestR testr.xsd">
>           goodbye
>        </r>
>    </larry>
> </mo>
>
> testr.xsd:
> <?xml version="1.0"?>
> <xsd:schema targetNamespace="urn:TestR"
>             xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
>             elementFormDefault="qualified">
>         <xsd:element name="r" type="xsd:string"/>
> </xsd:schema>
>
> testa.xsd:
> <?xml version="1.0"?>
> <xsd:schema targetNamespace="urn:TestA"
>             xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
>             elementFormDefault="qualified">
>         <xsd:element name="a" type="xsd:string"/>
> </xsd:schema>

Received on Wednesday, 7 February 2001 23:23:25 UTC