[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: newbie-ish DTD question: am i asking too much of XML, or of my brain

  • From: Ronald Bourret <rbourret@i...>
  • To: "xml-dev@i..." <xml-dev@i...>
  • Date: Tue, 21 Sep 1999 19:44:00 +0200

external dtd link
Rick Wayne wrote:

> i want my documents to consist of a "model" element.  a model can
> contain "topics" and "links", any number, in any order.  in turn, topics
> can contain topics and links, in any number, in any order.
>
> in (attempted) XML, with ATTLIST tags removed:
>
> <?XML version="1.0" encoding="UTF-8" standalone="no"?>
> <!ELEMENT model (topic* link*)>
> <!ELEMENT topic (topic* link*)>
> <!ELEMENT link>

Very close, but no cigar.  In a content model with multiple entries, the 
entries must be separated by a pipe symbol (|) (for choices) or a comma 
(for sequences). However, just putting in one of these won't give you what 
you want. For example:

   <!ELEMENT model (topic* | link*)>

means you can have either a bunch of topics or a bunch of links. Instead, 
what you need to do is put the zero-or-more operator (*) on the content 
group as a whole and a pipe between:

  <!ELEMENT model (topic | link)*>
  <!ELEMENT topic (topic | link)*>

Furthermore, you need to declare a content model for the link element, such 
as PCDATA (contains text) or EMPTY (contains nothing). For example:

  <!ELEMENT link (#PCDATA)>
 --or--
  <!ELEMENT link EMPTY>

Finally, you need to put your entire DTD in the internal subset (inside the 
DOCTYPE statement) or in an external DTD. For example, here's your DTD in 
the internal subset:

  <?XML version="1.0" encoding="UTF-8" standalone="no"?>
  <!DOCTYPE model [
     <!ELEMENT model (topic | link)*>
     <!ELEMENT topic (topic | link)*>
     <!ELEMENT link (#PCDATA)>
   ]>
   <model>...</model>

And here's your DTD in an external DTD.

     <!ELEMENT model (topic | link)*>
     <!ELEMENT topic (topic | link)*>
     <!ELEMENT link (#PCDATA)>

Assuming the external DTD file was named model.dtd and that file was in the 
same directory as your XML document, you could reference it from a DOCTYPE 
statement as follows:

  <?XML version="1.0" encoding="UTF-8" standalone="no"?>
  <!DOCTYPE model SYSTEM "model.dtd">
   <model>...</model>

-- Ron Bourret


xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.