Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem validating with DTD from within web app

 
Yan Lee
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

.....\jakarta-tomcat-5.5.7\bin\dtd\module-config.dtd

What steps to I need to take in my web application to teach it to looking into a some location under the deployment directory ??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic