February 16, 2002 - Defining the Grammar of Element Attributes | WebReference

February 16, 2002 - Defining the Grammar of Element Attributes

Yehuda Shiran February 16, 2002
Defining the Grammar of Element Attributes
Tips: February 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

The DTD should include definitions of the element attributes. The syntax of ATTLIST is quite complicated. In our mydvd XML file, week has two attributes, number and dvds_rented. They are character data (CDATA) and required (#REQUIRED). Here are the definitions of these two attributes:

<!ATTLIST week number CDATA #REQUIRED>
<!ATTLIST week dvds_rented CDATA #REQUIRED>
Here is the mydvd XML file:

  <?xml version="1.0"?>
  <?xml-stylesheet type="text/xsl" href="mydvd7.xsl"?>
  <!DOCTYPE sales SYSTEM "mydvd8.dtd">
    <sales>
      <summary>
        <heading>MyDVD Rental Store</heading>
        <subhead>Periodical Sales Report</subhead>
        <description>Sales Report for January, February, and &lt;&month;&gt; of 2001</description>
        <author>author: &preparedby;</author>
  	    <date>Jan 30, 2002</date>
      </summary>
      <data>
        <month>
          <name>January 2001</name>
          <week number="1" dvds_rented="12000" />
          <week number="2" dvds_rented="15000" />
          <week number="3" dvds_rented="18000" />
          <week number="4" dvds_rented="11800" />		  
        </month>
        <month>
          <name>February 2001</name>
          <week number="2" dvds_rented="12390" />
          <week number="3" dvds_rented="19050" />
          <week number="4" dvds_rented="11200" />		  
        </month>
        <month>
          <name>March 2001</name>
          <week number="1" dvds_rented="15300" />
          <week number="2" dvds_rented="12390" />
          <week number="3" dvds_rented="10050" />
          <week number="4" dvds_rented="11230" />		  
        </month>
      </data>
    </sales>