DTD - Is it the right way?
John E. Simpson
simpson at polaris.net
Mon Jul 5 15:53:32 BST 1999
At 01:28 PM 05/13/1999 +0000, suresh at niitblvl.niit.co.in wrote:
>...Below is a DTD I have written for Contacts. I have
>used a tool called as XML Spy. I have a few questions
>1. Is this is the right way of writing a DTD?
Sure -- although "a" right way might be a better way of putting it. As long
as the DTD is syntactically correct and leads to structurally sound
documents, any way of writing a DTD is as good as any other.
>2. The tool said that the DTD was valid, but I cant open it in IE5.
The best you'd be able to do in IE5 would be to open the DTD as a text
file. You may have misunderstood something important: that IE5 (and other
"XML browser/viewer"-type products) is meant not for viewing DTDs, but for
viewing *XML documents*. These may or may not be documents conforming to a
DTD (called valid and well-formed documents, respectively); but the DTD
itself isn't something a browser would need to display.
(Although it's correct, your DTD does have one odd feature -- which may not
be odd at all, of course, if your application demands it. The question I
have about it is whether you really need to specify multiple content models
(="formats") for a Person's FullName -- FirstName+MiddleInitials+LastName,
LastName+FirstName+MiddleInitials, and so on. Typically you'd just need to
pick one content model. If your application needs to read various formats,
it would be up to the app to modify the document structure to conform to
the DTD's single acceptable one; if it needs to "display" various formats,
this can be accomplished with a style sheet or a downstream application.)
So, given your DTD, the next step is to create a document based on it. This
might look something like the following:
<xml version="1.0" encoding="UTF-8">
<!DOCTYPE Contacts SYSTEM "Contacts.dtd">
... etc. ...
... etc. ...
(Replace "Contacts.dtd" in the above with the path to your DTD, whatever
Save the file, then view it (again, *not* the DTD) in IE5.
BTW, a better place for general XML questions might be the XML-L mailing
list. You can access XML-L and its archives, and/or subscribe and
unsubscribe to the list, at:
In theory, XML-DEV is for discussion about issues relating to the
development of XML software... although list members will tackle
practically any reasonable question. :)
John E. Simpson | The secret of eternal youth
simpson at polaris.net | is arrested development.
http://www.flixml.org | -- Alice Roosevelt Longworth
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at 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 at ic.ac.uk the following message;
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)
More information about the Xml-dev