You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Tony Zhang <tj...@us.ibm.com> on 2001/08/10 04:23:40 UTC

Schema Validation: Inconsistent Behavior on Attributes

Here is a simple example.  Just focusing on blue lines.
The problem is that the parser (xerces1.4.1) gives an error
"ANY---attribute avail must be declared", even it is declared in both both
Schemas.
Obviously, it thinks this attribute doesn't belong to any namespace.  I
know this because if I put either cam: or nik: in front of avail, it works.
SO the question is how come the parser knows attribute price belongs to nik
namespace but do not think avail should belong to cam namespace.
Or a more fundamental question is how does the parser decide which
namespace an attribute belongs, since the namespace of attributes are not
so explicit when they are declared and the attributes are often used in a
non-qualified form.
Instance XML file
<?xml version="1.0"?>
<cam:camera xmlns:cam="http://www.camera.org"
         xmlns:nik="http://www.nikon.com"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation='http://www.camera.org Camera1.xsd
http://www.nikon.com Nikon1.xsd'>
    <cam:vendor avail="now">
      <nik:Nikon price="100" >
        <nik:description/>
        <nik:model/>
      </nik:Nikon>
    </cam:vendor>
</cam:camera>
Schema 1.
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.camera.org"
            xmlns:cam="http://www.camera.org"
            elementFormDefault="qualified" >
    <element name="camera">
        <complexType>
          <sequence>
            <element name="vendor" type="cam:allcam" />
          </sequence>
        </complexType>
    </element>
    <complexType name="allcam">
        <sequence>
             <any namespace="##any" minOccurs="0" maxOccurs="unbounded"
processContents="lax" />
        </sequence>
        <anyAttribute namespace="##any" processContents="strict" />
    </complexType>
    <attribute name="avail" />
</schema>
Schema 2
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.nikon.com"
            xmlns:nik="http://www.nikon.com"
            elementFormDefault="qualified">
    <element name="Nikon" type="nik:coolpix" />
    <complexType name="coolpix">
        <sequence>
            <element name="description" type="string"/>
            <element name="model" type="string"/>
        </sequence>
        <attribute name="price" use="required" />
    </complexType>
    <attribute name="avail" />
</schema>



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