A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Refactoring for Software Design Smells: Managing Technical Debt
this week in the
OO, Patterns, UML and Refactoring
XML and Related Technologies
Joined: Feb 04, 2007
Apr 29, 2008 07:57:00
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?
SCJP 1.4, SCWCD for J2EE 1.4
Joined: Oct 14, 2005
Apr 29, 2008 12:21:00
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
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
, 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:
subject: DOCTYPE definition
dtd question / ambiguous content model. (from an old ibm test)
DTD and XML
local reference to dtd
XML within XML
SYSTEM vs PUBLIC
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015