RelaxNG Schema

Figure 1008. XML grammar defining languages Slide presentation
  1. REgular LAnguage for XML Next Generation (RelaxNG)

  2. Schematron

  3. XML Schema (XSD)

  4. Document Type Definition (DTD)

Figure 1009. Address list schema Slide presentation
Schema Doc instance
<element name="aBook">
    <element name="person">
      <element name="fullName">
      <element name="email">
    <fullName>Jim Bone</fullName>

exercise No. 5

Inventing a <book> grammar


In this exercise we develop a simple grammar aiming at book style documents.

Read the RELAX NG Tutorial. You may want to import the examples into your OxygenXML IDE. Based on this knowledge you ar being asked to model a schema describing simple <book> documents.

Use Oxygen XML Editor to create a RelaxNG book.rng schema suiting the subsequent document sample:

<book lang="en">
   <title>My first book</title>
       <paragraph>Some text.</paragraph>
       <paragraph>More text.</paragraph>
        <title>Go on ...</title>
        <paragraph lang="de">Hier kommt noch etwas.</paragraph>

        <title>Complex examples</title>
                <paragraph lang="es"/>
                        <paragraph>Two and more</paragraph>

The following rules shall be obeyed:

  • Valid documents must start with <book>.

  • A <book> element contains a <title> followed by at least one <chapter>.

  • Each <chapter> has (exactly one) a <title> which is being followed by at least one <paragraph> or <itemizedlist>.

  • The elements <title> and <paragraph> consist of ordinary text.

  • Both <book> and <para> elements may have an optional lang attribute like en, fi, es, it and so on. Use the data type NMTOKEN.

  • <itemizedlist> elements consist of at least one <listitem> element.

  • <listitem> elements consist of least one <paragraph> or <itemizedlist>.

You may want to start from the following file mybook.rng:

<?xml version="1.0" encoding="UTF-8"?>
        <ref name=""/>

    <define name="">
        <element name="book">

    <!-- TODO: extend me accordingly ... -->