jQuery in Action, 2nd edition*
The moose likes XML and Related Technologies and the fly likes how to validate an xml using DTD in DOM parser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "how to validate an xml using DTD in DOM parser" Watch "how to validate an xml using DTD in DOM parser" New topic
Author

how to validate an xml using DTD in DOM parser

Priya Sri
Ranch Hand

Joined: Mar 30, 2004
Posts: 84
Hi friends,

My requirement is like this :

A pdf will be submitted by the end user. The data will be passed to servlet as an xml request. We should use Dom Parser and get the fields from the xml request and to be stored in tables.

In my servlet, how to validate an XML using a DTD???

I have seen a part of code like this to validate xml using DTD :


code:
--------------------------------------------------------------------------------

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(true);

--------------------------------------------------------------------------------



Suppose I have specified the dtd name as book.dtd in the xml with the line like below

code:
--------------------------------------------------------------------------------

<!DOCTYPE book SYSTEM "book.dtd">

--------------------------------------------------------------------------------



where will this book.dtd to be stored??
1. is it at WSAD server where the servlet runs?
If so, how to specify the path in servlet that validate this xml using this dtd which resides in this location??

Thanks in Advance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to validate an xml using DTD in DOM parser