ZVON > Tutorials > XML Schema and Relax NG Tutorial |
Intro / Search / ZVON |
Index | >> Example 1 / 9 << | Prev | Next | |
We want to have the root element to be named "AAA", from null namespace and empty. The empty element is defined as a "complexType" with a "complexContent" which is a restriction of "anyType", but without any elements.
Valid document <AAA xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> |
Correct XML Schema (correct_0.xsd) <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > <xsd:element name="AAA"> <xsd:complexType> <xsd:complexContent> <xsd:restriction base="xsd:anyType"/> </xsd:complexContent> </xsd:complexType> </xsd:element> </xsd:schema> |
To specify, that element must be empty, use the "empty" element.
Valid document <AAA xmlns=""/> |
Correct Relax NG schema (correctRelax_0.rng) <grammar xmlns="http://relaxng.org/ns/structure/1.0" > <start> <element> <name ns="">AAA</name> <empty/> </element> </start> </grammar> Correct Relax NG schema (correctRelax_1.rng) |