jQuery in Action, 3rd edition
The moose likes XML and Related Technologies and the fly likes Problem validating with DTD from within web app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Problem validating with DTD from within web app" Watch "Problem validating with DTD from within web app" New topic

Problem validating with DTD from within web app

Yan Lee
Ranch Hand

Joined: Sep 15, 2003
Posts: 94
Hi all,
I am accessing information configured in an XML file using DOM (in a web application).

I have created a DTD to validate the XML file.
I have put the DTD in the /WEB-INF directory of my web app.

The code that parses the xml from within my web app is not able to locate the DTD during validation.

When I specify the location of the DTD on my file syste e.g. C:\myDTD.dtd, the app is able to locate it but when the location is /WEB-INF/myDTD.dtd, it is not able to.

I have the following questions:
1. How can I specify in my DOCTYPE that the DTD is located in the WEB-INF directory?
2. Do I need to do anything specific in the code to make the DTD availible to the xml processing code in the web app?

Thanks in advance for the help.
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
You can get the DOCTYPE in the XML file any way you can. I recommend Notepad. As for #2 -- you need to write yourself an EntityResolver. Check out the API docs for more information on that one.

Vijay P

Joined: Apr 03, 2000
Posts: 8
I have the same problem, if I have a DTD mydefn.dtd

And withing XML file I reference it in XML file as follows

<!DOCTYPE mydefn SYSTEM "dtd/mydefn.dtd">

1) In case of a Java Application, if I place the mydefn.dtd in dtd folder at the root of my application. It works.

2) In case of a Java Web Application it tries to look for mydefn.dtd in bin directory of Tomcat


What steps to I need to take in my web application to teach it to looking into a some location under the deployment directory ??

I agree. Here's the link: http://aspose.com/file-tools
subject: Problem validating with DTD from within web app
It's not a secret anymore!