ZVON > Tutorials > XML Schema and Relax NG Tutorial |
Intro / Search / ZVON |
Index | >> Example 1 / 4 << | Prev | Next | |
If we use "any" or "anyAttribute" elements and set their attribute "processContents" to value "strict", those elements/attributes, which are represented by the "any/anyAttribute" pattern must: have definition and must be valid with respect to that definition 3.10.1 The Wildcard Schema Component .
Valid document <foo:root xsi:schemaLocation="http://foo correct_0.xsd" xmlns:foo="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bar="http://bar" > <bar:x>1</bar:x> <bar:x>2</bar:x> </foo:root> Invalid document <foo:root xsi:schemaLocation="http://foo correct_0.xsd" xmlns:foo="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bar="http://bar" > <bar:x>1</bar:x> <x xmlns="">1</x> <bar:x>2</bar:x> </foo:root> Invalid document <foo:root xsi:schemaLocation="http://foo correct_0.xsd" xmlns:foo="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bar="http://bar" > <bar:x>1</bar:x> <bar:x>aaa</bar:x> </foo:root> |
Correct XML Schema (correct_0.xsd) <xsd:schema targetNamespace="http://foo" xmlns:xsd="http://www.w3.org/2001/XMLSchema" > <xsd:import namespace="http://bar" schemaLocation="correct_1.xsd"/> <xsd:element name="root"> <xsd:complexType> <xsd:sequence minOccurs="1" maxOccurs="1"> <xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="strict"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> Correct XML Schema (correct_1.xsd) <xsd:schema targetNamespace="http://bar" xmlns:xsd="http://www.w3.org/2001/XMLSchema" > <xsd:element name="x" type="xsd:integer"/> </xsd:schema> |