You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Marcus Wejderot <ma...@wejderot.se> on 2007/03/13 15:09:03 UTC

XML validation with extendable schema

I have an XML document that I suspect should not pass validation, but
does. I would very much appreciate some comments on this issue. The
document and schemas are included below. The <a/> element can include any
other element. The processContent attribute is set to "lax", meaning that
content is validated if a schema is found. Since a default schema is
specified, I believe that the <b/> and <c/> element should be validated
according to this schema. In this case, only the <b/> element should be
valid, but the document is considered valid! Is it something I have
missed, or is it a bug in Xerces?

Thanks,
Marcus


=================== a.xsd ===================
<?xml version="1.0" encoding="UTF-8"?>
   <xs:schema targetNamespace="http://a.com"
       xmlns:xs="http://www.w3.org/2001/XMLSchema"
       elementFormDefault="qualified" attributeFormDefault="unqualified">
       <xs:element name="a">
           <xs:complexType>
               <xs:complexContent>
                   <xs:restriction base="xs:anyType">
                       <xs:sequence>
                           <xs:any namespace="##other"
                                   processContents="lax"
                                   minOccurs="0" maxOccurs="unbounded"/>
                       </xs:sequence>
                   </xs:restriction>
               </xs:complexContent>
           </xs:complexType>
       </xs:element>
   </xs:schema>

=================== b.xsd =====================
<?xml version="1.0" encoding="UTF-8"?>
   <xs:schema targetNamespace="http://b.com"
       xmlns:xs="http://www.w3.org/2001/XMLSchema"
       elementFormDefault="qualified" attributeFormDefault="unqualified">
       <xs:element name="b" type="xs:string"/>
   </xs:schema>

=================== a.xml =====================
<?xml version="1.0" encoding="UTF-8"?>
<a:a xmlns:a="http://a.com" xmlns="http://b.com">
    <b/>
    <c/>
</a:a>


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


Re: XML validation with extendable schema

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
"Marcus Wejderot" <ma...@wejderot.se> wrote on 03/13/2007 10:09:03 AM:

> I have an XML document that I suspect should not pass validation, but
> does. I would very much appreciate some comments on this issue. The
> document and schemas are included below. The <a/> element can include 
any
> other element. The processContent attribute is set to "lax", meaning 
that
> content is validated if a schema is found. Since a default schema is
> specified, I believe that the <b/> and <c/> element should be validated
> according to this schema. In this case, only the <b/> element should be
> valid, but the document is considered valid! Is it something I have
> missed, or is it a bug in Xerces?

Not a bug. This is how lax [1] works. *If* a declaration is available the 
element must be valid with respect to it otherwise it's not strictly 
assessed [2]. The fact that you've provided a schema document for 
"http://b.com" isn't relevant.

> Thanks,
> Marcus
> 
> 
> =================== a.xsd ===================
> <?xml version="1.0" encoding="UTF-8"?>
>    <xs:schema targetNamespace="http://a.com"
>        xmlns:xs="http://www.w3.org/2001/XMLSchema"
>        elementFormDefault="qualified" 
attributeFormDefault="unqualified">
>        <xs:element name="a">
>            <xs:complexType>
>                <xs:complexContent>
>                    <xs:restriction base="xs:anyType">
>                        <xs:sequence>
>                            <xs:any namespace="##other"
>                                    processContents="lax"
>                                    minOccurs="0" maxOccurs="unbounded"/>
>                        </xs:sequence>
>                    </xs:restriction>
>                </xs:complexContent>
>            </xs:complexType>
>        </xs:element>
>    </xs:schema>
> 
> =================== b.xsd =====================
> <?xml version="1.0" encoding="UTF-8"?>
>    <xs:schema targetNamespace="http://b.com"
>        xmlns:xs="http://www.w3.org/2001/XMLSchema"
>        elementFormDefault="qualified" 
attributeFormDefault="unqualified">
>        <xs:element name="b" type="xs:string"/>
>    </xs:schema>
> 
> =================== a.xml =====================
> <?xml version="1.0" encoding="UTF-8"?>
> <a:a xmlns:a="http://a.com" xmlns="http://b.com">
>     <b/>
>     <c/>
> </a:a>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

[1] http://www.w3.org/TR/xmlschema-1/#Wildcard_details
[2] http://www.w3.org/TR/xmlschema-1/#key-sva

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

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