ZVON > Tutorials > XML Schema and Relax NG Tutorial
Index | >> Example 1 / 2 << | Prev | Next |
Contents > Annotation > Annotating your schema

Annotating your schema

  1. XML Schema
  2. Relax NG
XML Schema keys: annotation

1. XML Schema

If you want to add a human readable description of your schemas, use the element "documentation", which is a child of "annotation" element.

Valid document


<root xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > test </root>

Correct XML Schema (correct_0.xsd)


<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >

  <xsd:annotation>
    <xsd:documentation> My element "root", which contains only string. </xsd:documentation>
  </xsd:annotation>

  <xsd:element name="root" type="xsd:string"/>
</xsd:schema>

2. Relax NG

Relax NG allows you to place arbitrary elements from other namespaces into your schema.

Valid document


<root xmlns=""> test </root>

Correct Relax NG schema (correctRelax_0.rng)


<grammar xmlns="http://relaxng.org/ns/structure/1.0" >

  <start>
    <doc:documentation xmlns:doc="http://documentation.org/" > Element "root" must contain only a string. </doc:documentation>
    <element>
      <name ns="">root</name>
      <text/>
    </element>
  </start>
</grammar>