Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XML
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 8th, 2007, 06:20 PM
Authorized User
 
Join Date: Mar 2004
Location: , , Latvia.
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?

Reply With Quote
  #2 (permalink)  
Old April 9th, 2007, 09:00 AM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
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
Reply With Quote
  #3 (permalink)  
Old April 9th, 2007, 11:40 AM
Authorized User
 
Join Date: Mar 2004
Location: , , Latvia.
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?

Reply With Quote
  #4 (permalink)  
Old April 9th, 2007, 01:08 PM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:25 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.