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 Ramesh Gupta <ra...@eNode.com> on 2000/12/10 17:08:38 UTC
BUG: use="required" not enforced for global attributes
In the following schema [1], element 'foo' is required to have two
attributes -- 'bar' and 'baz'.
The following instance [2] validates successfully with Xerces 1.2.3.
If you remove the 'baz' attribute from the instance, Xerces will correctly
report that the attribute is required.
However, if you remove the 'foo:bar' attribute from the instance, Xerces
will still validate it successfully even though it is a required attribute.
Ramesh
[1] Schema
==========
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/1999/XMLSchema"
targetNamespace="FooNamespace"
xmlns:foo="FooNamespace"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/1999/XMLSchema
http://www.w3.org/1999/XMLSchema.xsd">
<import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2000/04/xml.xsd"/>
<element name="foo" type="foo:FooType"/>
<attribute name="bar" type="string"/>
<complexType name="FooType" content="empty">
<attribute ref="foo:bar" use="required"/>
<attribute name="baz" type="string" use="required"/>
</complexType>
</schema>
[2] Instance document
=====================
<?xml version="1.0" encoding="UTF-8"?>
<foo xmlns="FooNamespace"
xmlns:foo="FooNamespace"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xsi:schemaLocation="FooNamespace http://localhost/fooSchema.xsd"
foo:bar="here" baz="here"/>