Skip to content
Snippets Groups Projects
Commit 1474eecf authored by Goik Martin's avatar Goik Martin
Browse files

Extended RelaxNG example

parent b054fff2
No related branches found
No related tags found
No related merge requests found
......@@ -2423,12 +2423,19 @@ xmlns="http://docbook.org/ns/docbook">
<qandadiv>
<qandaentry>
<question>
<para>Read the <link
xlink:href="http://relaxng.org/tutorial-20011203.html">RELAX NG
Tutorial</link>. You may want to import the examples into your
OxygenXML <xref linkend="glo_IDE"/>. Based on this knowledge you
ar being asked to model a schema describing simple <tag
class="starttag">book</tag> documents.</para>
<para>Use <link
xlink:href="https://www.oxygenxml.com/xml_editor.html">Oxygen XML
Editor</link> to create a RelaxNG <filename>book.rng</filename>
schema suiting the subsequent document sample:</para>
<programlisting language="xml">&lt;book&gt;
<programlisting language="xml">&lt;book lang="en"&gt;
&lt;chapter&gt;
&lt;title&gt;Introduction&lt;/title&gt;
&lt;paragraph&gt;Some text.&lt;/paragraph&gt;
......@@ -2436,7 +2443,7 @@ xmlns="http://docbook.org/ns/docbook"&gt;
&lt;/chapter&gt;
&lt;chapter&gt;
&lt;title&gt;Go on ...&lt;/title&gt;
&lt;paragraph&gt;There is more to come here.&lt;/paragraph&gt;
&lt;paragraph lang="de"&gt;Hier kommt noch etwas.&lt;/paragraph&gt;
&lt;/chapter&gt;
&lt;/book&gt;</programlisting>
......@@ -2465,10 +2472,20 @@ xmlns="http://docbook.org/ns/docbook"&gt;
class="starttag">paragraph</tag> consist of ordinary
text.</para>
</listitem>
<listitem>
<para>Both <tag class="starttag">book</tag> and <tag
class="starttag">para</tag> elements may have an optional
<property>lang</property> attribute like <code>en</code>,
<code>fi</code>, <code>es</code>, <code>it</code> and so on.
Use the data type <code
xlink:href="http://www.kohsuke.org/relaxng/shorthand/ShortRNG.html#IDAPBSS">NMTOKEN</code>.</para>
</listitem>
</itemizedlist>
</question>
<answer>
<para>You may want to start from the following file
<filename>mybook.rng</filename>:</para>
<programlisting language="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;grammar
xmlns="http://relaxng.org/ns/structure/1.0"
......@@ -2480,35 +2497,13 @@ xmlns="http://docbook.org/ns/docbook"&gt;
&lt;define name="d.book"&gt;
&lt;element name="book"&gt;
&lt;oneOrMore&gt;
&lt;ref name="d.chapter"/&gt;
&lt;/oneOrMore&gt;
&lt;/element&gt;
&lt;/define&gt;
&lt;define name="d.chapter"&gt;
&lt;element name="chapter"&gt;
&lt;ref name="d.title"/&gt;
&lt;oneOrMore&gt;
&lt;ref name="d.paragraph"/&gt;
&lt;/oneOrMore&gt;
&lt;/element&gt;
&lt;/define&gt;
&lt;define name="d.title"&gt;
&lt;element name="title"&gt;
&lt;text&gt;&lt;/text&gt;
&lt;/element&gt;
&lt;/define&gt;
&lt;define name="d.paragraph"&gt;
&lt;element name="paragraph"&gt;
&lt;text&gt;&lt;/text&gt;
&lt;text/&gt;
&lt;/element&gt;
&lt;/define&gt;
<emphasis role="bold">&lt;!-- TODO: extend me accordingly ... --&gt;</emphasis>
&lt;/grammar&gt;</programlisting>
</answer>
</question>
</qandaentry>
</qandadiv>
</qandaset>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment