• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DOCTYPE definition

 
Karthick Sundaram
Greenhorn
Posts: 15
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm a beginner with XML and need some basic help.

This is the general external reference to a DTD.

<!DOCTYPE root-element SYSTEM "filename">

And this is a specific example.

<!DOCTYPE note SYSTEM "Note.dtd">

Where should the Note.dtd file be placed, so that the xml document is validated against this dtd?

Thanks,
Karthick
 
Paul Clapham
Sheriff
Pie
Posts: 20207
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The parser will treat "Note.dtd" as a path that is relative to the base URL of the XML document it is parsing.

So, usually this means you put the DTD in the same directory as the XML document. If the base URL is an http:// URL then you have to make sure the server will serve the DTD from the appropriate path.

And you have to make sure the parser actually has a base URL for the XML document. If you pass it an InputStream, for example, then it doesn't have one and thus it won't be able to find the DTD.

If you provide the parser with an EntityResolver which locates the DTD itself, then you can put the DTD anywhere you like, as long as the EntityResolver knows where you put it.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic