spacer
Yehuda Shiran February 17, 2002
Arbitrary-Length Entity References
Tips: February 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management
There are two types of entity references. The first type is a character-based pre-defined reference, such as the >. The second type of entity reference is that of user-defined unlimited-length references. Peek again at our mydvd XML file below. The description element is free text, showing the months of the year this sales report is for:

<description>Sales Report for January, February,  
  and &lt;&month;&gt; of 2001</description>
Two months, January and February, are written explicitly. The third month is written as an entity reference, &month;. You need to get the value of this entity reference from the DTD file. The relevant ENTITY statement is:

<!ENTITY month "April">
Notice that we put &lt; to the left of &month; and &gt; to its right. These additions are not related to &month;.

Another example entity reference is shown in the author element of mydvd:

<author>author: &preparedby;</author>
The entity reference &preparedby; needs to be substituted by a value from the DTD. Here is how we define it:

<!ENTITY preparedby "John Smith">
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>

People who read this tip also read these tips:

Look for similar tips by subject:

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Administering MySQL Databases on the Web Using PHP · Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
So what is an Oracle Nested Table? · E-Discovery Architectures 101 · eBay Embraces Big Sellers, Cyber Monday Trends