From 1474eecfc4dd6f363c8419e2b7efb9b21fd17b34 Mon Sep 17 00:00:00 2001 From: Martin Goik <goik@hdm-stuttgart.de> Date: Tue, 15 Aug 2017 11:48:20 +0300 Subject: [PATCH] Extended RelaxNG example --- XmlCross/xmlcross.xml | 53 ++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/XmlCross/xmlcross.xml b/XmlCross/xmlcross.xml index 61bc3e95d..2c06db3e5 100644 --- a/XmlCross/xmlcross.xml +++ b/XmlCross/xmlcross.xml @@ -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"><book> + <programlisting language="xml"><book lang="en"> <chapter> <title>Introduction</title> <paragraph>Some text.</paragraph> @@ -2436,7 +2443,7 @@ xmlns="http://docbook.org/ns/docbook"> </chapter> <chapter> <title>Go on ...</title> - <paragraph>There is more to come here.</paragraph> + <paragraph lang="de">Hier kommt noch etwas.</paragraph> </chapter> </book></programlisting> @@ -2465,10 +2472,20 @@ xmlns="http://docbook.org/ns/docbook"> 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"><?xml version="1.0" encoding="UTF-8"?> <grammar xmlns="http://relaxng.org/ns/structure/1.0" @@ -2480,35 +2497,13 @@ xmlns="http://docbook.org/ns/docbook"> <define name="d.book"> <element name="book"> - <oneOrMore> - <ref name="d.chapter"/> - </oneOrMore> - </element> - </define> - - <define name="d.chapter"> - <element name="chapter"> - <ref name="d.title"/> - <oneOrMore> - <ref name="d.paragraph"/> - </oneOrMore> - </element> - </define> - - <define name="d.title"> - <element name="title"> - <text></text> - </element> - </define> - - <define name="d.paragraph"> - <element name="paragraph"> - <text></text> + <text/> </element> </define> + <emphasis role="bold"><!-- TODO: extend me accordingly ... --></emphasis> </grammar></programlisting> - </answer> + </question> </qandaentry> </qandadiv> </qandaset> -- GitLab