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.
id attribute and can contain most tags as
children, the first being an optional name. For specifics you should
always consult the CNXML
Spec.
<example id='tboneexam'>
<figure id='tbonefig'>
<name>T-Bone Steak</name>
<media type='image/jpg' src='tbone.jpg'/>
</figure>
</example>
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.
figure tag has two attributes:
id - a unique ID, requiredorient - defines how multiple subfigures are to be displayed.
It takes two values, vertical or
horizontal, and will default to
horizontal.
figure tag is name which is used to
title a figure.
name 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 tag has two
attributes:
src - the location of the displayed mediatype - defines the type of media being
displayed, which can be any valid MIME
type.
caption which is
used to add a small caption to the figure.
<figure id='tbone'>
<name>T-Bone Steak</name>
<media type='image/jpeg' src='tbone.jpg'/>
<caption>
Upon successful completion of these documents, you should be able
to grill a steak that looks just as good!
</caption>
</figure>
subfigure tag is used when you want to
include more than one media,
code or table within the same
figure.
subfigure tag is similar to that
of figure. It has an optional
id attribute, an optional first child name tag, a single media, code or table, followed by an optional caption.
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'>
<name>Steaks</name>
<subfigure id='subfigtbone1'>
<name>T-Bone</name>
<media type='image/jpeg' src='tbone.jpg'/>
</subfigure>
<subfigure id='subfingnystrip1'>
<name>New York Strip</name>
<media type='image/jpeg' src='ny_strip.gif'/>
</subfigure>
<caption>
Upon successful completion of these documents, you
should be able to grill a steak that looks just as good!
</caption>
</figure>
Or
<figure orient='vertical' id='verfig'>
<name>Steaks</name>
<subfigure id='subfigtbone2'>
<name>T-Bone</name>
<media type='image/jpeg' src='tbone.jpg'/>
</subfigure>
<subfigure id='subfig2'>
<name>New York Strip</name>
<media type='image/jpeg' src='ny_strip.jpg'/>
</subfigure>
<caption>
Upon successful completion of these documents, you
should be able to grill a steak that looks just as good!
</caption>
</figure>
list tag is used to make lists. It has two
attributes:
id - a unique ID, requiredtype - defines the formatting of the
list. type takes the values
bulleted (default), enumerated,
named-item or inlinelist tag has two children: name, which is optional, and
item, which is where the list information is
stored.
<list id='marinade' type='enumerated'> <name>Beer Marinade</name> <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 resulting list will look like:
type attribute
in the list tag to named-item. Each of
the items in the named list will have a name.
<list id='marinade' type='named-item'> <name>Beer Marinade</name> <item><name>Step 1</name>pour beer into large bowl</item> <item><name>Step 2</name>add chili powder to taste</item> <item><name>Step 3</name>squeeze half lime into beer marinade</item> <item><name>Step 4</name>place steak in beer, let soak for 30 minutes</item> </list>The resulting list will look like:
| Beer Marinade | ||
| Step 1 | - | pour beer into large bowl |
| Step 2 | - | add chili powder to taste |
| Step 3 | - | squeeze half lime into beer marinade |
| Step 4 | - | place steak in beer, let soak for 30 minutes |
In order to make a good marinade follow these directions:<list id='marinade' type='inline'> <name>Beer Marinade</name> <item><name>Step 1</name>pour beer into large bowl</item> <item><name>Step 2</name>add chili powder to taste</item> <item><name>Step 3</name>squeeze half lime into beer marinade</item> <item><name>Step 4</name>place steak in beer, let soak for 30 minutes</item> </list>.The resulting list will look like: In order to make a good marinade follow these directions: Beer Marinade: Step 1 - pour beer into large bowl; Step 2 - add chili powder to taste; Step 3 - squeeze half lime into beer marinade; Step 4 - place steak in beer, let soak for 30 minutes
equation tag is used to set off and number
equations in CNXML documents by using ASCII text and embedded
media to display math. <equation id="eqn14"> <name>Euler's Relation</name> <media type='image/gif' src='euler.gif' /> </equation>
<equation id='eqn15'>
<name>Simple Arithmetic</name>
11+27=38
</equation>
This equation will display as:
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.
meaning
tag which is follwed 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'>
<name>T-Bone Steak</name>
<media type='image/jpeg' src='tbone.jpg'/>
</figure>
</example>
</definition>
T-Bone Steak![]() Figure 1 |
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 IDtype - required, specificies the type of
rule (e.g. theorem, axiom, rule of thumb, etc.)
<rule id='murph' type='law'>
<name>Murphy's Law</name>
<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>
Comments, questions, feedback, criticisms?