Hey, My question relates to DTDs. The two ways one can specify DTDs are either using the SYSTEM keyword in the <!DOCTYPE ...> element or the PUBLIC keyword. If a certain XML doc is sent from host A to host B and it has a DOCTYPE with PUBLIC keyword which references a URL like so: ... <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> ..... How is host B supposed to check the validity of this XML doc. Does it actually go out to the sun site to get the DTD. What if the sun site is down? Also, can I place DTDs on my own servers? TIA Pankaj
Yes, Host B goes to the sun site to get the DTD. Yes, if the Sun site is down, then the document can not be validated. Yes, you can put the DTD on any server on the network(it can be accessed from a webserver or the file system). The advantage of this particular DTD being on the Sun site is that there's one central document definition for this particular document type. If you have the same DTD on different servers, you have to make sure that they're synchronized.
Joined: Mar 13, 2001
Thanks for the reply. But that raises another question. I have used DTDs that are declared with DOCTYPE...PUBLIC in XML docs taht are passed between machines on an intranet setup. No access to the sun site. Yet I do not get a validation error. This was if I wanted to start a webapp using weblogic, say. The web.xml file that describes the webapp, has a PUBLIC DTD declaration. So the question is, how is the validation turned off in weblogic. I don't see an explicit switch/property to do this. Could it be that the turning off of the validation (or making it optional) a part of the XML doc itself? Thanks, Pankaj
Hi there! The point here is that the app in question either validates the XML according to the DTD or it does not. Or, put in another way, either it needs to, or it needs not. As long as your app is not required to validate the doc, you don't need access to the DTD, the DOCTYPE tag is just ignored. You should use DTD validation if you expect your app to receive input from external users, whose XML you will not be able to verify before input. You can not turn off validation in an XML doc. I don't know what 'weblogic' is, but probably (considered today's connectivity conditions around) it will not go to the web to check the DTD for a configuration file (if that's what 'web.xml' is). The point is that as long as you, as system administrator, are able to keep the config files proper, it would be a serious flaw in any system to let you have downtime because it cannot access a public DTD. This may change in the future, when connectivity is more or less assured everywhere. Good luck with your project! Regards, Marius
Joined: Feb 08, 2001
Pankaj, Which XML parser are you using? The parser that I'm using takes a boolean indicating whether the document is to be validated or not.