Summary: This is the second installment of the CNXML language tutorials. It is designed to give a more comprehensive look at the CNXML tags and explain some more advanced uses of the language. Includes helpful examples of CNXML tags, extending the module created in The Basic CNXML tutorial.
As is often the case in textbooks, authors will include
examples in the middle of a chapter or section. For this
reason CNXML provides a tag that allows an author to include
examples in a document. The example tag has a unique
id attribute and can contain most tags as
children, the first being an optional title. For specifics you should
always consult the CNXML
Spec.
<example id='tboneexam'>
<figure id='tbonefig'>
<title>T-Bone Steak</title>
<media id="image-example" display="block" alt="A T-bone Steak.">
<image type='image/jpg' src='tbone.jpg'/>
</media>
</figure>
</example>
The figure tag provides the structure for
creating a figure within a document. They can contain either
two or more subfigure tags, or
a single media, table, or code tag.
The figure tag has two attributes:
id - a unique ID, required orient - defines how multiple subfigures are to be displayed.
It takes two values, vertical or
horizontal, and will default to
horizontal.
The optional first tag of the figure tag is title which is used to
title a figure.
The title tag is followed by any of the tags
listed above; however, the most commonly used tag is media,
which is used to include any sort of media such as images,
video, music, or java applets. The media object tags have two required
attributes:
src - the location of the displayed media mime-type - defines the type of media being
displayed, which can be any valid MIME
type.
The final tag is the optional caption which is
used to add a small caption to the figure.
<figure id='tbone'>
<title>T-Bone Steak</title>
<media id="image-example" display="block" alt="A T-bone Steak.">
<image mime-type='image/jpeg' src='tbone.jpg'/>
</media>
<caption>
Upon successful completion of these documents, you should be able
to grill a steak that looks just as good!
</caption>
</figure>
The subfigure tag is used when you want to
include more than one media,
code or table within the same
figure.
The usage of the subfigure tag is similar to that
of figure. It has an optional
id attribute, an optional first child title tag, a single media, code or table, followed by an optional caption.
Now the orient attribute for figure becomes very important.
orient lets you specify whether the subfigures
should be displayed side-to-side or one on top of the other.
<figure orient='horizontal' id='horfig'>
<title>Steaks</title>
<subfigure id='subfigtbone1'>
<title>T-Bone</title>
<media id="image-example" display="block" alt="A T-bone Steak.">
<image type='image/jpeg' src='tbone.jpg'/>
</media>
</subfigure>
<subfigure id='subfingnystrip1'>
<title>New York Strip</title>
<media id="image-example" display="block" alt="A NY Strip.">
<image mime-type='image/jpeg' src='ny_strip.gif'/>
</media>
</subfigure>
<caption>
Upon successful completion of these documents, you
should be able to grill a steak that looks just as good!
</caption>
</figure>
<figure orient='vertical' id='verfig'>
<title>Steaks</title>
<subfigure id='subfigtbone2'>
<title>T-Bone</title>
<media id="image-example" display="block" alt="A T-bone Steak.">
<image mime-type='image/jpeg' src='tbone.jpg'/>
</media>
</subfigure>
<subfigure id='subfig2'>
<title>New York Strip</title>
<media id="image-example" display="block" alt="A NY Strip.">
<image mime-type='image/jpeg' src='ny_strip.jpg'/>
</media>
</subfigure>
<caption>
Upon successful completion of these documents, you
should be able to grill a steak that looks just as good!
</caption>
</figure>
The list tag is used to make lists. It has two
attributes:
id - a unique ID, required list-type - defines the formatting of the
list. list-type takes the values
bulleted (default), enumerated,
named-item or inlinelist tag has two children: title, which is optional, and
item, which is where the list information is
stored.
<list id='marinade' list-type='enumerated'>
<title>Beer Marinade</title>
<item>pour beer into large bowl</item>
<item>add chili powder to taste</item>
<item>squeeze half lime into beer marinade</item>
<item>place steak in beer, let soak for 30 minutes</item>
</list>
CNXML 0.6 gives you much more control over the list environment. Now you will be able to choose from eight preset bullet styles as well as an option that allows you to choose your own literal text to serve as the bullet style. The enumerated list type now offers several styles, including Arabic numerals, upper and lower case alphabet characters, and also upper and lower case Roman numerals. In addition to these changes, you can now also select to have your lists follow a stepwise progression. In CNXML 0.6 the named-item list has been slightly altered, and is now called a labeled-item list. As you may have guessed, the change is quite intuitive. Instead of using <name> to specify the item's label, you use <label>.
Here is an example of a stepwise enumerate list:
<list id="eip-165" list-type="enumerated" number-style="arabic" class="stepwise">
<title>Beer Marinade</title>
<item>pour beer into large bowl</item>
<item>add chili powder to taste</item>
<item>squeeze half lime into beer marinade</item>
<item>place steak in beer, let soak for 30 minutes</item>
</list>
The equation tag is used to set off and number
equations in CNXML documents by using ASCII text, MathML and embedded
media to display math.
The first child of equation is an optional title followed by any number of media tags.
<equation id="eqn14">
<title>Euler's Relation</title>
<media id="equation-example" display="block" alt="Euler's Relation.">
<image mime-type='image/gif' src='euler.gif' />
</media>
</equation>
<equation id='eqn15'>
<title>Simple Arithmetic</title>
11+27=38
</equation>
<equation id="eqn22">
<m:math>
<m:mn>11</m:mn>
<m:mo>+</m:mo>
<m:mn>27</m:mn>
<m:mo>=</m:mo>
<m:mn>38</m:mn>
</m:math>
</equation>
The definition tag is used to define a word in a
CNXML document. It has a required id attribute
and three children: term, meaning and example. How to use definition is a
little confusing, so don't forget to check out Example 7.
The first child tag should be term which contains the word/phrase
being defined. It is then followed by a meaning
tag which is followed by any number of examples. This process repeats for
all meanings.
<definition id='tbonedef'>
<term>T-Bone</term>
<meaning>
"The T-bone steak is cut between 1 and 3 inches thick and comes
from the center section of the short loin. This steak is
characterized by its T-shape bone, has a fine-grained shell and a
small tenderloin eye,"
<cite>http://www.chophousecalgary.com/steak.html</cite>.
</meaning>
<example id='tboneexam'>
<figure id='tbonefig'>
<title>T-Bone Steak</title>
<media id="image-example" display="block" alt="A T-bone Steak.">
<image mime-type='image/jpeg' src='tbone.jpg'/>
</media>
</media>
</figure>
</example>
</definition>
| T-Bone Steak |
|---|
![]() |
The rule tag is used to insert a rule, such as a
theorem, axiom, or rule of thumb, into a cnxml document. It
has two attributes:
id - required, unique ID type - required, specificies the type of
rule (e.g. theorem, axiom, rule of thumb, etc.)
The statement tag is used inside a
rule tag and defines the statement of
the rule. It has an optional id attribute,
which, like all IDs, must be unique. It also has two
children, para
and equation.
The proof tag is used inside the
rule tag and marks the proof of the rule. It
has an optional id attribute and may contain
another rule, para, equation, figure, or list tag.
<rule id='murph' type='law'>
<title>Murphy's Law</title>
<statement>
<para id='murphp1'>
If there are two or more ways to do something, and one of those
ways can result in a catastrophe, then someone will do it.
</para>
</statement>
<proof>
<para id='murphp2'>
Edward A. Murphy, Jr. was one of the engineers on the
rocket-sled experiments that were done by the U.S. Air Force in
1949 to test human acceleration tolerances (USAF project
MX981). One experiment involved a set of 16 accelerometers
mounted to different parts of the subject's body. There were two
ways each sensor could be glued to its mount, and somebody
methodically installed all 16 the wrong way around. Murphy then
made the original form of his pronouncement, which the test
subject (Major John Paul Stapp) quoted at a news conference a
few days later
<cite>http://www.lylemariam.com/murphy.htm</cite>.
</para>
</proof>
</rule>
If there are two or more ways to do something, and one of those ways can result in a catastrophe, then someone will do it.
Edward A. Murphy, Jr. was one of the engineers on the rocket-sled experiments that were done by the U.S. Air Force in 1949 to test human acceleration tolerances (USAF project MX981). One experiment involved a set of 16 accelerometers mounted to different parts of the subject's body. There were two ways each sensor could be glued to its mount, and somebody methodically installed all 16 the wrong way around. Murphy then made the original form of his pronouncement, which the test subject (Major John Paul Stapp) quoted at a news conference a few days later http://www.lylemariam.com/murphy.htm.
Thanks for making it through another tutorial. I'm sure that you still want to know more so here's a link to The Advanced CNXML.
"If you are ready to start creating new materials in Connexions, or adapting and reusing existing materials, this guide and tutorial will help you get started. Questions are always welcome to […]"