spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column103


Web Services, Part VIII: Reading DTDs with JavaScript

Technical Lead
Thomson Reuters (Markets) LLC
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?


Defining XML File Structure

The DTD file contains several types of declarations. First, it includes declarations about the XML document structure. You need to specify each element's content. The root element sales, (see page 2 for a listing of our mydvd XML file), includes the elements summary and data:

<!ELEMENT sales (summary, data)>

Be sure to put all child elements within parentheses and separated by commas. The summary element includes the following elements: heading, subhead, description, author, and date:

<!ELEMENT summary (heading, subhead, description, author, date)>

The data element includes one or more elements of month. You specify repetition with an asterisk:

<!ELEMENT data (month*)>

The month element consists of two elements: name and week (one or more instances):

<!ELEMENT month (name, week*)>

We have reached leaf cells in our XML tree structure. Leaf-cell elements do not include elements but are pure Parsed Character Data (PCDATA). You define their content as (#PCDATA):

<!ELEMENT heading (#PCDATA)>
<!ELEMENT subhead (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT date (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT week (#PCDATA)>

The DTD should also 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>


Next: How to define entity references

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: February 11, 2002
Revised: February 11, 2002

URL: http://www.webreference.com/js/column103/3.html