Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 8th, 2007, 06:20 PM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default The start and the end in the DTD format

When reading theoretical material about the DTD format I learn that the whole DTD document should be wrapped into one element like this:

<!DOCTYPE TVSCHEDULE [
<!ELEMENT .....
.....
]>

However, I cannot get Altova (http://www.altova.com/xmlspy) to see this kind of document as a well-formed DTD and I cannot validate an XML document against such DTD. It returns error "Character 'D' is gramatically unexpected in column 3 at line 1". How come?

When I chose a command to create a new DTD by Altova, it set up an empty sample of DTD where I could see what it considers a well-formed DTD. Namely it wants the document to start with an XML definition

<?xml version="1.0" encoding="UTF-8"?>

and then does not expect any "DOCTYPE" tag but simply the element/attribute definitions. But DTD even is not an XML document itself, is it!

Is it some kind of Altova error or have I misunderstood something?

 
Old April 9th, 2007, 09:00 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>the whole DTD document should be wrapped into one element

It helps to try and use the correct terminology - it avoids a lot of misunderstandings. There's no such thing as a "DTD document", and the thing you are wrapping it in isn't an element.

A DTD that exists in a file of its own is called an "external DTD subset". This never contains the <!DOCTYPE ... > delimiters. The <!DOCTYPE ... > delimiters always appear in the instance document, immediately after the XML declaration if there is one. For example your instance document can be:

<!DOCTYPE doc SYSTEM "my.dtd">
<doc>Hello</doc>

which refers to an external DTD subset in file my.dtd that might contain the single line:

<!ELEMENT doc (#PCDATA)>

The syntax you showed is appropriate for an internal DTD subset (a DTD contained within the instance document that it describes, which might be:

<!DOCTYPE doc[
<!ELEMENT doc (#PCDATA)>
]>
<doc>Hello</doc>

I've left out the XML declaration <?xml version="1.0"?> in these examples because it's optional.

I'm not sure exactly what you did to get the error message from XML Spy.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 9th, 2007, 11:40 AM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much, mhkay, that makes perfect sense! :D It is, for example, similar to embedding or linking to a CSS or JavaScript code within a HTML document.

Still, what about an external DTD subset being an XML document? It's not correct, is it? So, even if the XML declaration does not give any errors, it should not be written in an external DTD subset file, should it?

 
Old April 9th, 2007, 01:08 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Technically, an XML declaration can appear only at the start of the document entity (that is, the main XML document). However, a Text Declaration, which is for most purposes the same thing as an XML declaration, can appear at the start of any external entity, including the external DTD subset.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Automated tool to convert XML from DTD to DTD lsantos2000 XSLT 2 October 17th, 2007 08:21 AM
Fill in table based on start and end date drm237 Access 3 April 24th, 2007 07:55 AM
start date and an end date Corey Access 1 January 16th, 2006 12:37 AM
validate start and end tags saban Word VBA 1 January 13th, 2006 01:11 PM
help with dtd file format jsbxml XML 0 January 17th, 2005 04:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.