<?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="m9000">

  <name>The Basic CNXML</name>
  <metadata>
  <md:version>2.33</md:version>
  <md:created>2001/02/07</md:created>
  <md:revised>2005/03/09 10:50:02 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:author 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: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="charlet">
      <md:firstname>Charlet</md:firstname>
      
      <md:surname>Reedstrom</md:surname>
      <md:email>charlet@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>CNXML</md:keyword>
    <md:keyword>Connexions</md:keyword>
    <md:keyword>content</md:keyword>
    <md:keyword>document</md:keyword>
    <md:keyword>markup</md:keyword>
    <md:keyword>namespace</md:keyword>
    <md:keyword>tag</md:keyword>
    <md:keyword>XML</md:keyword>
  </md:keywordlist>

  <md:abstract>This is a basic introduction to the CNXML language.  It includes a description on how to begin a CNXML module and also examples of the basic tags needed to start writing in CNXML.</md:abstract>
</metadata>
  
  <content>
    <section id="sec1">
      <name>Starting with CNXML</name>
      <para id="intro">
	CNXML is a lightweight XML markup language for
	marking up educational content. The goal of CNXML is to convey
	the content of the material and not a particular presentation.
	<link src="http://cnx.rice.edu">The Connexions Project</link>
	uses the Connexions Markup Language (CNXML) as its primary
	language for storing documents.  Now let's get started!
      </para>
    </section>

    <section id="mark_up">
      <name>CNXML Tags</name>
      
      <section id="document_section">
	<name>Document</name>
	<para id="document">
	  All CNXML documents have as their root the <code type="inline">document</code> tag. Everything about the
	  document including it's metadata and content are contained
	  within the document tag. It is important that you understand
	  the basic structure for a CNXML document. The structure is
	  as follows:

	  <list id="org_list">
	    <name>Document (root tag)</name>
	    <item><term>Name</term> (required)</item>
	    <item><term>Metadata Section</term> (optional)</item>
	    <item><term>Content Section</term> (required)</item>
	  </list>
	</para>
	
	<para id="note_para">
	  <note type="warning">
	    There is some additional information that is required for
	    the document to validate. This is explained under the
	    section titled <cnxn target="required_stuff">Other
	    Required Stuff</cnxn>.
	  </note>
	</para>
	
	<para id="document_attributes">
	  The document tag has one required attribute:
	  <list id="documentlist">
	    <item>
	      <code type="inline">id</code> - a unique ID given to the
	      document (usually assigned to you by the Connexions
	      project)
	    </item>
	  </list>
	</para>

	<section id="id_info">
	  <name>ID Requirements</name>
	  <para id="id">
	    One major difference between CNXML and other markup
	    languages is the <code type="inline">id</code> attribute
	    requirement. Certain tags require that you include the
	    <code type="inline">id</code> attribute. These tags are listed
	    below:
	    <list id="required_id">
	      <item><code type="inline">document</code></item>
	      <item><code type="inline">para</code></item>
	      <item><code type="inline">equation</code></item>
	      <item><code type="inline">rule</code></item>
	      <item><code type="inline">definition</code></item>
	      <item><code type="inline">exercise</code></item>
	      <item><code type="inline">list</code></item>
	    </list>

	    So, if you are going to use any of the above tags, be sure
	    to add the <code type="inline">id</code> attribute and
	    give it a unique 'id'. An example of this is shown below.
	  </para>
	  
	  <example id="id_example">
	    <code type="block">
	      <![CDATA[
<para id='uniqueid1'>
  This is an example to illustrate the use of the <code>id</code> attribute.
</para>
<para id='uniqueid2'>
  This paragraph has a different id than the last.
</para>
	     ]]>
	    </code>
	  </example>
	  <note type="note">
	    Any tag can contain an <code type="inline">id</code>
	    attribute. This is useful if you want to link to the
	    information contained in a particular tag.
	  </note>
	</section>

	<section id="namespace_declaration">
	  <name>Namespaces</name>
	  <para id="namespaces">
	    The <code type="inline">document</code> tag should also
	    contain any <term>namespace</term> declarations.  <cnxn document="m10159">Namespaces</cnxn> allow us to easily use
	    other mark-up languages within CNXML without having to
	    worry about whether tag name collision will occur.  For
	    simple documents using only CNXML, you need to include the
	    CNXML namespace attribute <code type="inline">xmlns='http://cnx.rice.edu/cnxml'</code>. Any
	    additional languages need to be declared as well and
	    should be given their own prefixes.  For example, to
	    associate the MathML namespace with the prefix "m",
	    include the following attribute: <code type="inline">xmlns:m='http://www.w3.org/1998/Math/MathML'</code>.
	    This states that any tag with a prepended "m" will be
	    interpreted as a MathML tag while any tag without a prefix
	    will be interpreted as CNXML.
	  </para>

	  <example id="namespace_example">
	    <code type="block">
<![CDATA[<document id='doc1' xmlns='http://cnx.rice.edu/cnxml'>]]>
	    </code>
	  </example>
	</section>
      </section>

      <section id="name">
	<name>Name</name>
	<para id="namep1">
	  The <code type="inline">name</code> tag can be used with
	  many CNXML tags to hold the name of its parent.  This tag
	  can only contain information in ASCII text. I mention it
	  here to allow you to put in the name of the module (since I
	  mentioned that it was the first required tag in the document
	  tag).
	</para>

	<example id="nameexamp">
	  <code type="block"><![CDATA[<name>Grilling a Good Steak</name>]]></code>
	</example>
	
	<note type="note">Please see the <link src="http://cnx.rice.edu/cnxml/0.5/spec">CNXML 0.5
	  specification</link> to see if a tag can be named.</note>
      </section>

      <section id="content">
	<name>Content</name>
	<para id="adding_content">
	  Now that you have the <code type="inline">document</code>
	  tag set up with an id and namespace info, the next thing to
	  do with your document is add content. By 'content' I mean
	  the text that will make up the bulk of your document. <note type="note">Strictly speaking the metadata should precede
	  information about content, but we will leave this until
	  later.</note> All of this content is conveniently placed in
	  the <code type="inline">content</code> tag. Every CNXML
	  document will have one <code type="inline">content</code>
	  tag. The body of the document will be here inside the
	  <code type="inline">content</code> tag.
	</para>
	<para id="structural_tags_para">
	  Structural tags are the tags which are used inside of the
	  <code type="inline">content</code> tag to give structure to
	  the document. These tags are discussed below.
	</para>

	<section id="content_tags">
	  <name>Structure Tags</name>
	  <para id="contentp1">
	    Some of the structure tags are <cnxn target="section">section</cnxn>, <cnxn target="para">para</cnxn>,
	    <cnxn target="document">document</cnxn>, and <cnxn target="content">content</cnxn>.
	  </para>
	  <para id="already">
	    We have already discussed the <cnxn target="document">document</cnxn> and <cnxn target="content">content</cnxn>
	    tags, so we will proceed with a short description and
	    examples of the other other tags listed.
	  </para>

	  <section id="para">
	    <name>Para</name>
	    <para id="parap1">
	      Text can be inserted into documents by using the <code type="inline">para</code> tag.  Each para has a required
	      <code type="inline">id</code> which must be unique
	      within the document.
	    </para>
	    <example id="paraexamp">
	      <code type="block">
<![CDATA[
<para id='intro'>
  I have eaten many steaks in my life and none have been more satisfying
  than the backyard-grill cooked steak.  Maybe this is because of the
  relaxing nature of drinking a beer, being outside, and lounging that
  accompanies the grilling procedure.  Maybe it is because of the aroma
  of the grill and the beef perfectly seasoned to your taste.  Either
  way, this document shows how a good steak can be prepared.
</para>]]>
	      </code>
	    </example>
	  </section>

	  <section id="section">
	    <name>Section</name>
	    <para id="secp1">
	      As often is the case in textbooks, chapters are divided
	      into smaller sections.  Because it is often necessary to
	      segment text for better understanding and coherence,
	      CNXML has included a <code type="inline">section</code>
	      tag.
	    </para>
	    <para id="secp2">
	      The section tag has one required attribute, <code type="inline">id</code>, and a required first child tag,
	      <cnxn document="m9000" target="name">name</cnxn>.
	    </para>
	    <example id="secexamp">
	      <code type="block">
		<![CDATA[
<section id='ingredsec'>
  <name>Ingredients</name>
    <list> ... </list>
</section>
<section id='marinadesec'>
  <name>Marinade</name>
  <para id='marinate'> ... </para>
    <list id='marinade'> ... </list>
  <para id='tobecontinued'> ... </para>
</section>
<section id='grillingsec'>
  <name>Grilling</name>
  <para id='prepgrill'> ... </para>
  <para id='grilling'> ... </para>
</section>]]>
	      </code>
	      <para id="secexampp1">
		Obviously ellipses would be replaced by appropriate text.
	      </para>
	    </example>
	  </section>  
	</section>

	<section id="Inline_tags">
	  <name>Inline Tags</name>
	  <para id="inline_tags_para">
	    Inline tags are used to embed content and functionality
	    inside of the <cnxn target="structural_tags">structural
	    tags</cnxn>. Some of the more commonly used tags are
	    discussed below.
	  </para>

	  <section id="emphasis">
	    <name>Emphasis</name>
	    <para id="emphp1">
	      The <code type="inline">emphasis</code> tag is used to
	      emphasize text in a CNXML document where emphasis in
	      text would be needed or desired.  It is important to
	      note that this refers to <emphasis>semantic</emphasis>
	      emphasis and not a typeface, although many stylesheets
	      may choose to render it visually with a different
	      typeface.
	    </para>
	    <example id="emphexamp">
	      <code type="block">
<![CDATA[
<para id='intro'>
  I have eaten many steaks in my life and none have been more satisfying
  than the backyard-grill cooked steak.  Maybe this is because of the
  relaxing nature of drinking a beer, being outside, and lounging that
  accompanies the grilling procedure.  Maybe it is because of the aroma
  of the grill and the beef <emphasis>perfectly</emphasis> seasoned to
  your taste.  Either way, this document shows how a good steak can be
  prepared.
</para>]]>
	      </code>
	    </example>
	  </section>

	  <section id="term">
	    <name>Term</name>
	    <para id="termp1">
	      The <code type="inline">term</code> tag is used to mark
	      words or phrases which are being defined.  However, its
	      use is confined to either a <cnxn target="para">para</cnxn> or <cnxn target="definition" document="m9007">definition</cnxn> tag.  The <code type="inline">term</code> tag has one optional
	      attribute:
	      <list id="term_attributes">
		<item><code type="inline">src</code> - a URL
		  specifying the source or definition of the
		  term.</item>
	      </list>
	    </para>
	    <example id="termexamp">
	      <code type="block">
<![CDATA[
<para id='marinade'>
  To ensure the best flavor possible, it is necessary to marinate the
  beef.  A steak <term src='http://marinade.com'>marinates</term> when
  left to sit in a prepared sauce, or <term>marinade</term>, where it
  will absorb the flavors of the ingredients.  Marinating may take as
  little as 15 minutes or as long as 6 hours and should
  <emphasis>always</emphasis> be done in the refrigerator and
  <emphasis>not</emphasis> at room temperature.
</para>]]>
	      </code>
	    </example>
	  </section>
	  
	  <section id="note">
	    <name>Note</name>
	    <para id="notep1">
	      The <code type="inline">note</code> tag creates an "out
	      of line" note to the reader, which could be a warning,
	      point of interest, etc.  The type of note is specified
	      by an optional <code type="inline">type</code> attribute.
	    </para>
	    <example id="notexamp">
	      <code type="block">
<![CDATA[
<para id='intro'>
  I have eaten many steaks in my life and none have been more
  satisfying than the backyard-grill cooked steak.  Maybe this is
  because of the relaxing nature of drinking a beer, being outside,
  and lounging that accompanies the grilling procedure.  <note
  type='warning'>Excessive drinking or fun may result in overcooked or
  burned steak.</note> Maybe it is because of the aroma of the grill
  and the beef <emphasis>perfectly</emphasis> seasoned to your taste.
  Either way, this document shows how a good steak can be prepared.
</para>]]>
	      </code>
	      <para id="notep2">
		The above markup will display as: 
	      </para>
	      <para id="notep3">
		I have eaten many steaks in my life and none have been
		more satisfying than the backyard-grill cooked steak.
		Maybe this is because of the relaxing nature of
		drinking a beer, being outside, and lounging that
		accompanies the grilling procedure.  <note type="warning">Excessive drinking or fun may result in
		overcooked or burned steak.</note> Maybe it is because
		of the aroma of the grill and the beef
		<emphasis>perfectly</emphasis> seasoned to your taste.
		Either way, this document shows how a good steak can
		be prepared.
	      </para>

	    </example>
	  </section>
	  
	  <section id="cnln">
	    <name>CNXN and Link</name>
	    <para id="cnlnp1">
	      The <code type="inline">cnxn</code> and <code type="inline">link</code> tags are the two tags in CNXML
	      used for linking to other documents.  The difference in
	      the two tags are that cnxns are used for linking to
	      other documents in the Connexions system while links are
	      used for linking to general documents on the internet.
	    </para>
	    <para id="cnxn">
	      The <code type="inline">cnxn</code> tag has four
	      attributes
	      <list id="cnxnlist">
		<item>
		  <code type="inline">target</code> - targets a
		specific tag </item>
		<item>
		  <code type="inline">document</code> - targets a
		specific document by its ID </item>
		<item>
		  <code type="inline">version</code> - targets a
		specific version of a document
		</item>
		<item>
		  <code type="inline">strength</code> - designates the
		  degree to which the linked information is related to
		  the current document
		</item>
	      </list>
	      The <code type="inline">version</code> attribute is
	      optional.  When not specified the cnxn will default the
	      link to the most current version of the document.  It
	      may seem pointless, but it is actually quite useful.  If
	      you specify a specific version of a document, it will
	      never change, meaning important parts, such as
	      paragraphs or figures, will not disappear without
	      warning.
	    </para>
	    <para id="cnxn2">
	      The <code type="inline">target</code> and <code type="inline">document</code> attributes can be used
	      together or alone.  If both are used then you will link
	      to a particular tag in another document.  If only <code type="inline">document</code> is used, you will link to
	      another document.  If only <code type="inline">target</code> is used, you will link to a
	      particular tag within the current document.
	    </para>
	    <para id="cnxn2b">
	      The <code type="inline">strength</code> attribute is
	      optional.  It can give the reader an indication of how
	      related the additional information is to the current
	      discussion.
	    </para>

	    <example id="cnxn_info">
	      <name>CNXN Example</name>

	      <para id="cnxn_info_para">
		The cnxn tag does not have to have a description of
		the destination in order to be used. For example,
		let's say you want to link to a figure inside the page
		but are unsure what to name the cnxn. You could you
		use a cnxn similar to the one below:
		<code type="block">
		  <![CDATA[
		<cnxn target='figure1'/>
		  ]]></code>		
		When you use a cnxn such as the example above, a
		substitution will be made since no text was inserted
		into the tag. So, the above example would render as:
		<code type="inline">
		  <![CDATA[
		  Figure 1
		  ]]></code>	
		or
		<code type="inline">
		  <![CDATA[
		  Reference]]>
		</code>
		depending on whether or not the system was able to
		find a suitable substitution.
		In most cases you can use text in the cnxn to describe
		the destination as in:
		<code type="block">
		  <![CDATA[
		<cnxn target='figure1'>Steak Figure</cnxn>
		  ]]></code>
	      </para>
	    </example>
	    
	    <para id="link">
	      The <code type="inline">link</code> tag, on the other
	      hand, has only a required <code type="inline">src</code>
	      tag which contains a URL for the target webpage.
	    </para>
	    <example id="cnlnexamp">
	      <code type="block">
		<![CDATA[
<para id='tobecontinued'>
  I'll be adding to this document in <cnxn document='m9006' >The
  Intermediate CNXML</cnxn> which focuses on more advanced CNXML tags.
  For more marinades see the <link src='http://www.2eatcab.com'>Angus
  Beef website</link>.  Finally, a good resource is the <cite>Steak
  Lover's Cookbook -- William Rice; Paperback</cite>.
</para>
		]]>
	      </code>
	      <para id="noteex10a">
		The above markup will display as: 
	      </para>
	      <para id="noteex10b">
		I'll be adding to this document in <cnxn document="m9006">The Intermediate CNXML</cnxn>
		  which focuses on more advanced CNXML tags.  For more
		  marinades see the <link src="http://www.2eatcab.com">Angus Beef
		  website</link>.  Finally, a good resource is the
		  <cite>Steak Lover's Cookbook -- William Rice;
		  Paperback</cite>.
	      </para>

	    </example>
	  </section>

	  <section id="cite">
	    <name>Cite</name>
	    <para id="citep1">
	      The <code type="inline">cite</code> tag is used to refer
	      to non-electronic materials within a document, primarily
	      containing the title of a work.  See <cnxn target="cnlnexamp"/>.
	    </para>
	  </section>

	  <section id="quote">
	    <name>Quote</name>
	    <para id="quote_para">
	      The <code type="inline">quote</code> tag is used to
	      denote that some text is a direct quote from some other
	      source. The quote tag has a <code type="inline">type</code> attribute which denotes
	      whether the quote is <code type="inline">inline</code>
	      or <code type="inline">block</code>.
	    </para>
	    <example id="quote_example">
	      <para id="quote_para_example">
		<code type="block"><![CDATA[<para id='steakquote'>
  Everyone has an opinion on how a steak should be cooked. <quote
  type='inline'>"A good steak should be pink in the middle and black
  on the outside."</quote> Although this may sound reasonable many
  remember the words of George Washington: <quote type='block'>"In any
  free country a man should have the ability to purchase a nice rare
  steak."</quote>
</para>]]></code>
		Everyone has an opinion on how a steak should be
		cooked. <quote type="inline">"A good steak should be
		pink in the middle and black on the outside."</quote>
		Although this may sound reasonable many remember the
		words of George Washington: <quote type="block">"In
		any free country a man should have the ability to
		purchase a nice rare steak."</quote>
	      </para>
	    </example>
	  </section>
	  
	  <section id="foreign">
	    <name>Foreign</name>
	    <para id="foreign_para">
	      The <code type="inline">foreign</code> tag is used to
	      denote that a foreign word or phrase is being used.
	    </para>
	    <example id="foreign_example">
	      <para id="foreign_para_example">
		<code type="block"><![CDATA[<para id='steakquote2'>
  In many latin american countries steak is called <foreign>carne
  asada</foreign>.
</para>]]></code>
		In many latin american countries steak is called
		  <foreign>carne asada</foreign>.
	      </para>
	    </example>
	  </section>
	</section>
      </section>
    </section>
  
    <section id="pause4">
      <name>Document Example Code</name>
      <para id="pause4p1">
	Below is an example of what your document could look like if
	you included all the tags above to make a document about
	making a steak.
      </para>
      <code type="block">
	<![CDATA[
      <document id='meat'
	xmlns='http://cnx.rice.edu/cnxml'
	>  
      <name>Grilling a Good Steak</name>

      <content>    

        <section id='intro'>
          <para id='intro'>
	    I have eaten many steaks in my life and none have been more
	    satisfying than the backyard-grill cooked steak.  Maybe this is
	    because of the relaxing nature of drinking a beer, being
	    outside, and lounging that accompanies the grilling procedure.
            <note type='warning'>Excessive drinking or fun may result in
	    overcooked or burned steak.</note> Maybe it is because of the
	    aroma of the grill and the beef <emphasis>perfectly</emphasis>
	    seasoned to your taste.  Either way, this document shows how a
	    good steak can be prepared.
          </para>
        </section>

        <section id='marinate_section'>	      
          <para id='marinate'>
	    To ensure the best flavor possible, it is necessary to marinate
	    the beef.  A steak <term>marinates</term> when left to sit in
            <term>marinade</term>, or prepared sauce, where it will absorb
	    the flavor of the ingredients.  Marinating may take as little as
	    15 minutes or as long as 6 hours and should
            <emphasis>always</emphasis> be done in the refrigerator and
            <emphasis>not</emphasis> at room temperature.
          </para>
        </section>

        <section  id='tobecontinued_section'>	      
          <para id='tobecontinued'>
	    I'll be adding to this document in <cnxn document='m9006'
	    >The Intermediate CNXML</cnxn> which focuses on more
	    advanced CNXML tags.  For more marinades see the <link
	    src='http://www.2eatcab.com'>Angus Beef website</link>.
	    Finally, a good resource is the <cite>Steak Lover's Cookbook --
	    William Rice</cite>.
          </para>
        </section>

      </content>
      </document>
	]]>
      </code>
      <para id="pause4p2">
	See how <link src="http://cnx.rice.edu">Connexions</link>
	would render <cnxn document="m10275">this example</cnxn>.
      </para>
    </section>

    <section id="required_stuff">
      <name>Other Required Stuff</name>
      <para id="doctype">
	The first line in any XML file should be the XML declaration.
	(Strictly speaking, this is optional, but it's a good practice
	to follow).  The XML declaration looks like this: <code type="inline"> <![CDATA[<?xml version="1.0"
	standalone="no"?>]]> </code>, and must not be preceeded by any
	blank lines or whitespace.  After this we declare what
	Document Type Definition (DTD) we'll be using for this
	document.  (Strictly speaking, this is optional too.  However,
	we must include it if we want to validate our document as
	CNXML).  For flexibility, Connexions has made several DTDs
	available to allow authors to <cnxn document="m10258">combine
	other markup languages with CNXML</cnxn> within a document.
	The DTD you specify will depend on which languages you wish to
	use in your document.  For simple documents using only CNXML,
	the declaration is:
      </para>
      <example id="cnxmldoctypeexamp">
	<code type="block">
	  <![CDATA[
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5//EN" 
	  "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_plain.dtd">
]]>
	</code> 
      </example>
      <para id="mathmldtp1">
	For CNXML with MathML the declaration would be:
      </para>

      <example id="mathmldoctypeexamp">
	<code type="block">
	  <![CDATA[
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" 
	  "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
]]>
	</code> 
      </example>
    </section>
    
    <section id="fin">
      <name>Conclusions</name>
      <para id="finp1">
	Remember that when composing documents it is always best to
	consult <link src="http://cnx.rice.edu/cnxml/0.5/spec/">the
	CNXML Spec</link> for any questions regarding the exact usage
	of CNXML tags.  For more advanced topics see <cnxn document="m9006">The Intermediate CNXML</cnxn> or <cnxn document="m9007">The Advanced CNXML</cnxn>, which concludes
	the cooking lesson.
      </para>
    </section>
  </content>
</document>
