ZVON > Tutorials > XML Schema and Relax NG Tutorial |
Intro / Search / ZVON |
Index | >> Example 1 / 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 arbitrary number of any attributes from any namespace.
Valid document <root xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> Valid document <root xsi:noNamespaceSchemaLocation="correct_0.xsd" a="1" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> Valid document <root xsi:noNamespaceSchemaLocation="correct_0.xsd" x="2" baz:x="2" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:baz="http://baz" /> |
Correct XML Schema (correct_0.xsd) <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > <xsd:element name="root"> <xsd:complexType> <xsd:anyAttribute namespace="##any" processContents="skip"/> </xsd:complexType> </xsd:element> </xsd:schema> |
The element "anyName" says that the attribute can have any name from any namespace. The "anyName" and "nsName" elements (which represent an infinite number of names) must be repeated, so you can say only that you allow either 0+ (zeroOrMore) or 1+ (oneOrMore) such attributes. See (7.3. Restrictions on attributes).
Valid document <root xmlns=""/> Valid document <root a="1" xmlns=""/> Valid document <root a="2" baz:x="2" xmlns="" xmlns:baz="http://baz" /> |
Correct Relax NG schema (correctRelax_0.rng) |