Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
 Discussion Forums
 HTML, XML, JavaScript...
 Software Reviews
 Editors,Others...
 Top100
 JavaScript Tutorials, ...
 Tutorials
 ASP, CSS, Databases...
 Discussion List
 FAQ, Roundup, Configure ...
 Authoring
 HTML, JavaScript, CSS...
 Design
 Layout, Navigation,...
 Graphics
 Tools, Colors, Images...
 Software
 Browsers, Editors, XML...
 Internet
 Domains, E-Commerce, ...
 WDVL Resources
  Intermdiate, Tutorials,...
 WDVL
 Discussion Lists, Top 100,...
 Technology Jobs


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Top 10 Articles
  1. Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
  2. JavaScript Tutorial for Programmers
  3. Design
  4. JavaScript Tutorial for Programmers - Objects
  5. JavaScript Tutorial for Programmers - JavaScript Grammar
  6. JavaScript Tutorial for Programmers - Versions of JavaScript
  7. Cascading Style Sheets
  8. JavaScript Tutorial for Programmers - Embedding JavaScript
  9. JavaScript Tutorial for Programmers - Functions
  10. Authoring JavaScript
Domain Name Lookup
Search to find the availability of a domain name. Just enter the complete domain name with extension (.com, .net, .edu)

Writing Our Own ML without a Net: Examples

April 12, 1999

So now we're going to create our own markup language (ML) that will be used throughout the rest of this article (both parts). We could start by creating a DTD, but the DTD syntax is complicated and not the way some of us naturally think about markup. Trust me -- we don't need the (DTD) net, at least not yet.

Some of you may recall my fondness for the Beatles from my first \ XML article. Let's create an XML description of a tiny fraction of my Beatles collection. In fact, we'll call this Collection Markup Language, or Collection ML for short. Why not Beatles ML? Because it will have general elements that are not at all explicitly associated with the Beatles. Why not Record ML? Because the collection may contain CDs, record albums (for those of us old enough to remember vinyl), books, and so forth. (Like most small XML examples, the language will be a bit contrived, meant more for illustrative purposes than to be useful in and of itself.)

Examples XML documents, DTD, and images Several small XML documents needed to follow the remainder of this article. Install them anywhere you wish, but subsequent downloads should be in the same location (folder).
Examples/doingit1.zip (approx. 54 KB) Requires Zip. Depending on your browser, you'll probably want to do a Save As (Download). If you don't have zip utilities, download each file separately.
Zip Contents: Explanation:
Examples/collection1.xml correct XML document without DTD reference
Examples/collection1.dtd correct DTD which describes Collection ML
Examples/collection1bugs.xml contains several XML syntax bugs for you to find
Examples/collection1dtd.xml references local (SYSTEM) DTD by relative path
Examples/collection1pubdtd.xml references public (PUBLIC) DTD by URL
Examples/collection1bugsdtd.xml references a DTD containing a DTD syntax error
Examples/collection1bugs.dtd DTD with a syntax error
Examples/collection1pubbugs.xml invalid document with respect to public DTD
Examples/collection1xml.gif GIF showing how IE5 displays XML (default)
Examples/mathML.gif GIF showing how Amaya displays MathML
Examples/mathML1.xml a simple MathML document
Examples/mathML2.xml another simple MathML document

After you unzip or download the files, take a close look at Examples/collection1.xml. (With some browsers, you may needed to use a text editor to view the XML file, reproduced below for your convenience.)

A Collection consists of Book and CD elements in no particular order. I'd like to be able to enter the information and deal with the presentation and ordering later (in part 2 of this article). Most of the elements in Collection ML have few if any attributes. There's no particular reason for this limitation other than to keep the example relatively simple. In fact, where I used attributes as opposed to elements may seem a bit arbitrary; this will be covered in the section To E or Not To E: Elements vs. Attributes. Also, except for Collection, Book, CD, and Chart, the elements are not very hierarchical; only a few elements can contain other elements. However, this is arguably a reasonable way to express the Book and CD information, so we won't be too harsh on the language creator. (The Owner element and owner attribute of Collection refer to the same thing, so one is redundant.) The Book element has optional nested elements Notes and Rating. The Label element has an optional attribute called country. Peak has optional elements weeks and country.

<?xml version="1.0" standalone="yes" ?>

<!-- A Collection consists of Book and CD elements 
in no particular order. -->

<Collection owner="Ken Sall" location="nevermind">
  <Owner>Ken Sall</Owner>
  <Book>
  <Title>Complete Beatles Chronicle, The</Title>
  <Author>Lewisohn, Mark</Author>
  <Type>Chronology</Type>
  <Published publisher="Harmony Books">
  1992</Published>
  <Rating>5 stars</Rating>
  <Notes>
  Covers the years 1957 through 1970. No solo info.
  Great appendices with chart info, discography, 
  composer index,radio, tv, and live performances, 
  and much more.
  </Notes>
  </Book>
  <CD>
  <Title>Band on the Run</Title>
  <Artist>McCartney, Paul and Wings</Artist>
  <Chart>
    <Peak weeks="4">1</Peak>
    <Peak country="UK">1</Peak> <!-- guess -->
  </Chart>
  <Type>Rock</Type>
  <Label>Capitol</Label>
  <Label country="UK">EMI</Label>
  <AlbumReleased>1973</AlbumReleased>
  <Remastered format="gold CD">1993</Remastered>
  <Remastered format="2 disc box set with booklet">
  1999</Remastered>
  </CD>
  <CD>
  <Title>Venus and Mars</Title>
  <Artist>McCartney, Paul and Wings</Artist>
  <Chart>
    <Peak weeks="1">1</Peak>
    <Peak country="UK">2</Peak> <!-- guess -->
  </Chart>
  <Type>Rock</Type>
  <Label>Capitol</Label>
  <Label country="UK">EMI</Label>
  <AlbumReleased>1975</AlbumReleased>
  <Remastered format="gold CD with 3 bonus tracks">
  1994</Remastered>
  </CD>
  <Book>
  <Title>Many Years From Now</Title>
  <Author>McCartney, Paul</Author>
  <Type>Autobiographical</Type>
  <Published publisher="Henry Holt and Company">
  1997</Published>
  <!-- Notice the absence of Notes and 
  Rating elements. I haven't read this book yet. 
  This illustrates some optional elements that 
  are children of Book element.
  -->
  </Book>
</Collection>

What's It All About, Ælfred?
Doing It With XML, Part 1
To E or Not To E: Elements vs. Attributes


Up to => Home / Authoring / Languages / XML / Tutorials / DoingIt




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers