ZVON > Tutorials > XML Schema and Relax NG Tutorial |
Intro / Search / ZVON |
Index | >> Example 4 / 10 << | Prev | Next | |
Please, send all comments, bug-reports, and contributions to Jiri.Jirat@systinet.com. Thank you very much.
XML Schema keys: anyAttributeThe root element named "root" can have an arbitrary number of attributes from some particular namespaces, let's say "http://bar" and "http://baz". The "namespace" attribute will be set to value "http://bar http://baz".
Valid document <root xsi:schemaLocation="http://foo correct_0.xsd" bar:a="1" xmlns="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bar="http://bar" /> Valid document <root xsi:schemaLocation="http://foo correct_0.xsd" baz:a="1" xmlns="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:baz="http://baz" /> Invalid document <root xsi:schemaLocation="http://foo correct_0.xsd" a="1" xmlns="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> Invalid document <foo:root xsi:schemaLocation="http://foo correct_0.xsd" bzz:a="1" xmlns:foo="http://foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bzz="http://bzz" /> |
Correct XML Schema (correct_0.xsd) <xsd:schema targetNamespace="http://foo" xmlns:xsd="http://www.w3.org/2001/XMLSchema" > <xsd:element name="root"> <xsd:complexType> <xsd:anyAttribute namespace="http://bar http://baz" processContents="skip"/> </xsd:complexType> </xsd:element> </xsd:schema> |
We will specify all attributes from namespaces "http://bar" and "http://baz" using the "nsName" element.
Valid document <root bar:a="1" xmlns="http://foo" xmlns:bar="http://bar" /> Valid document <root baz:a="1" xmlns="http://foo" xmlns:baz="http://baz" /> Invalid document <root a="1" xmlns="http://foo" /> Invalid document <foo:root bzz:a="1" xmlns:foo="http://foo" xmlns:bzz="http://bzz" /> |
Correct Relax NG schema (correctRelax_0.rng) |