ZVON > Tutorials > XML Schema and Relax NG Tutorial |
Intro / Search / ZVON |
Index | >> Example 3 / 4 << | Prev | Next | |
Please, send all comments, bug-reports, and contributions to Jiri.Jirat@systinet.com. Thank you very much.
XML Schema keys: type, nameThere is no name clash, because the elements and types are in different "symbol space". In other words, you can name your element "b" and some simpleType "b" too at the same time.
Valid document <a xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <b>xx</b> </a> |
Correct XML Schema (correct_0.xsd) <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > <xsd:element name="a" type="a"/> <xsd:complexType name="a"> <xsd:sequence> <xsd:element name="b" type="b"/> </xsd:sequence> </xsd:complexType> <xsd:simpleType name="b"> <xsd:restriction base="xsd:string"/> </xsd:simpleType> </xsd:schema> |
In Relax NG, there is no clash among the names of elements, attributes and patterns.
Valid document <a xmlns=""> <b>xx</b> </a> |
Correct Relax NG schema (correctRelax_0.rng) <grammar datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" ns="" xmlns="http://relaxng.org/ns/structure/1.0" > <start> <ref name="a"/> </start> <define name="a"> <element name="a"> <ref name="b"/> </element> </define> <define name="b"> <element name="b"> <text/> </element> </define> </grammar> |