Read everything before doing anything.
The objects of this assignment are:
See instructor's sample files
See a note about <interleave>
See a solution allowing nested <ul>
See a solution not allowing nested
<ul>
The catalog example used in part two of Assignment 1 had no specification for its “grammar.” Here is an English-language description of that grammar, which you should turn into an RNG specification. We've expanded upon it to use features of RNG that aren't available in a DTD. New information has a vertical bar at the side.
A <catalog>
consists of a
<company>
element followed by one
or more <department>
elements.
A <company>
element contains plain text.
A <department>
contains one or more
<item>
elements. It must have a
name
attribute and a unique code
attribute.
A color specification is either a single
<color>
element
(for those items that come in only one color), or
a <color-list>
(for items that come in multiple colors),
or an <sku>
element
(for items that have no color). These
are further defined as:
The <color-list>
element contains one or more <color>
elements.
First, we define inline elements as the
<em>
and <strong>
elements,
which may contain text and other inline elements. Given that
definition, the <summary>
and
<description>
elements may contain:
Text with inline elements
The <p>
(paragraph) element, which may
contain text with inline elements.
The <ul>
element, which contains
<li>
elements.
Each <li>
element may contain text
with inline elements and
<p>
(paragraphs).
You may have <ul>
elements
within an <li>
if you wish. This
is not a requirement, but it might make your
RNG a bit easier to write if you allow this nesting.
Notice that this is a highly recursive definition. Here's an example of
a valid <description>
<description xmlns:xh="http://www.w3.org/1999/xhtml"> The <xh:strong><xh:em>Sup-R Frying Pan</xh:em></xh:strong> is such a deal! <xh:p> Made of <xh:strong>heavy-duty</xh:strong> aluminum alloy, it assists food preparation with: </xh:p> <xh:ul> <xh:li>A non-conductive handle.</xh:li> <xh:li><xh:p>Non-stick coating</xh:p> (it's vitamin-enriched, too!)</xh:li> </xh:ul> <xh:p>Buy one <xh:em>right now!</xh:em></xh:p> </description>
Please use namespaces to implement this subset of XHTML, as in the
example above. The namespace URI for XHTML is
http://www.w3.org/1999/xhtml
.
You will also need to produce mixed content
with <interleave>
. See
information about a problem you might encounter.
Note: You will want to add some of this XHTML to your file to test that your RNG file handles it properly. I will test your RNG against one of my own sample files.
Your files should be saved as
plain ASCII text, but that does not mean that
they must both end with the extension .txt
.
If your name is Joe Doakes, your RNG file should have a name like
doakes_j_3.rng
and the XML file should have a name
like doakes_j_3.xml
. You may remove the
<!DOCTYPE>
from the XML file, as it is no longer
needed.
Use the msvalidate.bat
file on Windows, or
msvalidate.sh
shell script on Unix/Linux. The
validator will give no error messages if everything is OK.
If you've named your files as shown above, you would type:
msvalidate doakes_j_3.rng doakes_j_3.xml