<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_plain.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="m9006">

  <name>The Intermediate CNXML</name>

  <metadata>
  <md:version>2.19</md:version>
  <md:created>2001/01/29</md:created>
  <md:revised>2004/02/24 11:45:29 US/Central</md:revised>
  <md:authorlist>
      <md:author id="rars">
      <md:firstname>Ricardo</md:firstname>
      <md:othername>Anthony</md:othername>
      <md:surname>Radaelli-Sanchez</md:surname>
      <md:email>ricky@alumni.rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="selc">
      <md:firstname>Sarah</md:firstname>
      
      <md:surname>Coppin</md:surname>
      <md:email>coppin@alumni.rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="mizar">
      <md:firstname>Christine</md:firstname>
      
      <md:surname>Donica</md:surname>
      <md:email>mizar@alumni.rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="brentmh">
      <md:firstname>Brent</md:firstname>
      <md:othername>Michael</md:othername>
      <md:surname>Hendricks</md:surname>
      <md:email>brentmh@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>caption</md:keyword>
    <md:keyword>CNXML</md:keyword>
    <md:keyword>codeblock</md:keyword>
    <md:keyword>codeline</md:keyword>
    <md:keyword>equation</md:keyword>
    <md:keyword>figure</md:keyword>
    <md:keyword>media</md:keyword>
    <md:keyword>section</md:keyword>
    <md:keyword>subfigure</md:keyword>
  </md:keywordlist>

  <md:abstract>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.</md:abstract>
</metadata>
  
  <content>    
    <section id="example">
      <name>Example</name>
      <para id="examp1">
	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
	<code>id</code> attribute and can contain most tags as
	children, the first being an optional <cnxn target="name" document="m9000">name</cnxn>.  For specifics you should
	always consult the <link src="http://cnx.rice.edu/technology/cnxml/0.5/spec">CNXML
	Spec</link>.
      </para>
      <example id="exampexamp">
	<code type="block">
	  <![CDATA[
<example id='tboneexam'>
  <figure id='tbonefig'>
    <name>T-Bone Steak</name>
    <media type='image/jpg' src='tbone.jpg'/>
  </figure>
</example>
	  ]]>
	</code>
      </example>
    </section>

    <section id="figure">
      <name>Figure</name>
      <para id="figp1">
	The <code>figure</code> tag provides the structure for
	creating a figure within a document.  They can contain either
	two or more <cnxn target="subfigure">subfigure</cnxn> tags, or
	a single <cnxn target="media">media</cnxn>, <cnxn target="table" document="m9007">table</cnxn>, or <cnxn target="code" document="m9007">code</cnxn> tag.
      </para>
      <para id="figp2">
	The <code>figure</code> tag has two attributes:
	<list id="figlist">
	  <item><code>id</code> - a unique ID, required</item>
	  <item><code>orient</code> - defines how multiple <cnxn target="subfigure">subfigure</cnxn>s are to be displayed.
	  It takes two values, <code>vertical</code> or
	  <code>horizontal</code>, and will default to
	  <code>horizontal</code>.
	  </item>
	</list>
      </para>
      <para id="name">
	The optional first tag of the <code>figure</code> tag is <cnxn target="name" document="m9000">name</cnxn> which is used to
	title a figure.
      </para>
      <para id="media">
	The <code>name</code> 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:
	<list id="medialist">
	  <item><code>src</code> - the location of the displayed media</item>
	  <item>
	    <code>type</code> - defines the type of media being
	    displayed, which can be any valid <link src="http://www.ietf.org/rfc/rfc1341.txt?number=1341">MIME</link>
	    type.
	    <list id="MIME">
	      <item>audio/FILETYPE - audio/mp3, audio/wav, etc.</item>
	      <item>video/FILETYPE - video/qt, video/mov, etc.</item>
	      <item>image/FILETYPE - image/png, image/gif, etc.</item>
	      <item>application/FILETYPE - application/PostScript,
		application/x-java-applet, etc.</item>
	    </list>
	  </item>
	</list>
      </para>
      <para id="caption">
	The final tag is the optional <code>caption</code> which is
	used to add a small caption to the figure.
      </para>
      <example id="figexamp">
	<code type="block">
	  <![CDATA[
<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>
	  ]]>
	</code>
      </example>
    </section>
    
    <section id="subfigure">
      <name>Subfigure</name>
      <para id="subp1">
	The <code>subfigure</code> tag is used when you want to
	include more than one <cnxn target="media">media</cnxn>,
	<cnxn target="code" document="m9007">code</cnxn> or <cnxn target="table" document="m9007">table</cnxn> within the same
	<cnxn target="figure">figure</cnxn>.
      </para>
      <para id="subp2">
	The usage of the <code>subfigure</code> tag is similar to that
	of <cnxn target="figure">figure</cnxn>.  It has an optional
	<code>id</code> attribute, an optional first child <cnxn target="name" document="m9000">name</cnxn> tag, a single <cnxn target="media">media</cnxn>, <cnxn target="code" document="m9007">code</cnxn> or <cnxn target="table" document="m9007">table</cnxn>, followed by an optional <cnxn target="caption">caption</cnxn>.
      </para>
      <para id="subp3">
	Now the <code>orient</code> attribute for <cnxn target="figure">figure</cnxn> becomes very important.
	<code>orient</code> lets you specify whether the subfigures
	should be displayed side-to-side or one on top of the other.
      </para>
      <example id="subfigexamp">
	<para id="subp4">
	  <code type="block">
	  <![CDATA[
<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>
	  ]]>
	  </code>
	  Or
	  <code type="block">
	  <![CDATA[
<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>
	    ]]>
	  </code>
	</para>
      </example>
    </section>

    <section id="list">
      <name>List</name>
      <para id="listp1">
	The <code>list</code> tag is used to make lists.  It has two
	attributes:
	<list id="listlist">
	  <item><code>id</code> - a unique ID, required</item>
	  <item><code>type</code> - defines the formatting of the
	  list.  <code>type</code> takes the values
	  <code>bulleted</code> (default), <code>enumerated</code>,
	  <code>named-item</code> or <code>inline</code></item>
	</list>
	The <code>list</code> tag has two children: <cnxn target="name">name</cnxn>, which is optional, and
	<code>item</code>, which is where the list information is
	stored.
      </para>
      <example id="listexamp">
	<name>Example List</name>
	<para id="reglist">
	  <code type="block">
	    <![CDATA[
<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>
	    ]]>
	  </code>
	  The resulting list will look like:
	  <list id="marinadedisplay" 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>
	</para>
      </example>

      <example id="namedlistexample">
	<name>New List Types Example</name>
	<section id="namedlistsec">
	  <name>Named Item Lists</name>
	  <para id="namedpara">
	    CNXML 0.5 sees the introduction of two new types of
	    lists. The first type is known as a named item list. To
	    use this type of list set the <code>type</code> attribute
	    in the list tag to <code>named-item</code>. Each of
	    the items in the named list will have a name.
	    <code type="block">
	      <![CDATA[
<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>
	      ]]>
	    </code>
	    The resulting list will look like:
	    <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>
	  </para>
	</section>
	
	<section id="inlinelists">
	  <name>Inline Lists</name>
	  <para id="inlinelistpara">
	    The other new type of list is the inline list. This
	    type is used to specify semantically that a list is
	    present. For example:
	    <code type="block">
	      <![CDATA[ 
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>.
	      ]]>
	    </code>
 
	    The resulting list will look like: In order to make a good
	    marinade follow these directions:
	    
	    <list id="marinade2" 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>
	  </para>
	</section>
      </example>
    </section>
    
    <section id="equation">
      <name>Equation</name>
      <para id="eqnp1a">
	The <code>equation</code> tag is used to set off and number
	equations in CNXML documents by using ASCII text and embedded
	<cnxn target="media">media</cnxn> to display math.  <note type="note">It is strongly encouraged, however, to use
	equation with <cnxn document="m9008">MathML</cnxn> tags when
	displaying math.</note>
      </para>

      <section id="nonmathml">
	<name>ASCII Text and Images</name>
	<para id="eqnp2">
	  The first child is an optional <cnxn target="name" document="m9000">name</cnxn> followed by any number of <cnxn target="media">media</cnxn> tags embedded into ASCII text.
	</para>
	<example id="equationexample">
	  <para id="eqnpara">
	    <code type="block">
	    <![CDATA[
<equation id="eqn14">
  <name>Euler's Relation</name>
  <media type='image/gif' src='euler.gif' />
</equation>
	    ]]>
	    </code>
	    <code type="block">
	    <![CDATA[
<equation id='eqn15'>
  <name>Simple Arithmetic</name>
    11+27=38
</equation>
	    ]]>
	    </code>
	    This equation will display as: 
	    <equation id="eqn15">
	      <name>Simple Arithmetic</name>
	      11+27=38
	    </equation>
	  </para>
	</example>
      </section>
    </section>

    <section id="definition">
      <name>Definition</name>
      <para id="defp1">
	The <code>definition</code> tag is used to define a word in a
	CNXML document.  It has a required <code>id</code> attribute
	and three children: <cnxn target="term" document="m9000">term</cnxn>, <code>meaning</code> and <cnxn target="example">example</cnxn>.  How to use definition is a
	little confusing, so don't forget to check out <cnxn target="definitionexamp"/>.
      </para>
      <para id="defp2">
	The first child tag should be <cnxn target="term" document="m9000">term</cnxn> which contains the word/phrase
	being defined.  It is then followed by a <code>meaning</code>
	tag which is follwed by any number of <cnxn target="example">example</cnxn>s.  This process repeats for
	all meanings.
      </para>
      <example id="definitionexamp">
	<code type="block">
	  <![CDATA[
<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>
	  ]]>
	</code>
	<para id="defpara">
	  <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>
	</para>
      </example>
    </section>

    <section id="rule">
      <name>Rule</name>
      <para id="rule_par1">
	The <code>rule</code> tag is used to insert a rule, such as a
	theorem, axiom, or rule of thumb, into a cnxml document.  It
	has two attributes:
	<list id="rulelist">
	  <item><code>id</code> - required, unique ID</item>
	  <item><code>type</code> - required, specificies the type of
	  rule (e.g. theorem, axiom, rule of thumb, etc.)
	  </item>
	</list>
	It may also have an optional <cnxn target="name" document="m9000">name</cnxn> and it must have one or more
	<cnxn target="statement">statement</cnxn> tags and zero or
	more <cnxn target="proof">proof</cnxn> or <cnxn target="example">example</cnxn> tags.
      </para>

      <section id="statement">
	<name>Statement</name>
	<para id="state_p1">
	  The <code>statement</code> tag is used inside a
	  <code>rule</code> tag and defines the statement of
	  the rule.  It has an optional <code>id</code> attribute,
	  which, like all IDs, must be unique.  It also has two
	  children, <cnxn target="para" document="m9000">para</cnxn>
	  and <cnxn target="equation">equation</cnxn>.
	</para>
      </section>
      
      <section id="proof">
	<name>Proof</name>
	<para id="proof_p1">
	  The <code>proof</code> tag is used inside the
	  <code>rule</code> tag and marks the proof of the rule.  It
	  has an optional <code>id</code> attribute and may contain
	  another rule, <cnxn target="para" document="m9000">para</cnxn>, <cnxn target="equation">equation</cnxn>, <cnxn target="figure">figure</cnxn>, or <cnxn target="list" document="m9000">list</cnxn> tag.
	</para>
      </section>

      <section id="ruleexmpsec">
	<name>Using rule</name>
	<example id="ruleexmp">
	  <code type="block">
	    <![CDATA[
<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>
	    ]]>
	  </code>
	  <para id="rulepara">
	    <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>
	  </para>
	</example>
      </section>
    </section>

    <section id="end">
      <name>Finishing Remarks</name>
      <para id="endp1">
	Thanks for making it through another tutorial.  I'm sure that
	you still want to know more so here's my link (actually a
	<cnxn target="cnxn" document="m9000">cnxn</cnxn>) to <cnxn document="m9007">The Advanced CNXML</cnxn>.  And remember to
	<emphasis>always</emphasis> consult <link src="http://cnx.rice.edu/technology/cnxml/0.5/spec">the CNXML
	Spec</link> when writing documents.
      </para>
    </section>
  </content>
</document>
