OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

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

[ Lists Home | Date Index | Thread Index ]
  • From: Ronald Bourret <rbourret@ito.tu-darmstadt.de>
  • To: "xml-dev@ic.ac.uk" <xml-dev@ic.ac.uk>
  • Date: Tue, 21 Sep 1999 19:44:00 +0200

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@ic.ac.uk
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@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS