ZVON > Tutorials > XML Schema and Relax NG Tutorial |
Intro / Search / ZVON |
Index | >> Example 6 / 10 << | Prev | Next | |
The root element named "root" must have one arbitrary element from any namespace.
Valid document <root xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <a/> </root> Valid document <root xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <x:b xmlns:x="http://foo" /> </root> Invalid document <root xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> Invalid document <root xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <a/> <x:b xmlns:x="http://foo" /> </root> |
Correct XML Schema (correct_0.xsd) <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > <xsd:element name="root"> <xsd:complexType> <xsd:sequence minOccurs="1" maxOccurs="1"> <xsd:any namespace="##any" minOccurs="1" maxOccurs="1" processContents="skip"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> Correct XML Schema (correct_1.xsd) <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > <xsd:element name="root"> <xsd:complexType> <xsd:sequence minOccurs="1" maxOccurs="1"> <xsd:any namespace="##any" processContents="skip"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> |
The element "anyName" says that the element can have any name from any namespace.
Valid document <root xmlns=""> <a/> </root> Valid document <root xmlns=""> <x:b xmlns:x="http://foo" /> </root> Invalid document <root xmlns=""/> Invalid document <root xmlns=""> <a/> <x:b xmlns:x="http://foo" /> </root> |
Correct Relax NG schema (correctRelax_0.rng) |