[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xerces-j-user
Subject:    Re: XML validation with extendable schema
From:       Michael Glavassevich <mrglavas () ca ! ibm ! com>
Date:       2007-03-13 15:52:34
Message-ID: OFB1FE4BE1.5E9B446C-ON8525729D.0054F7CB-8525729D.005735DC () ca ! ibm ! com
[Download RAW message or body]

"Marcus Wejderot" <marcus@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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic