getting the entire DTD in the output file

Hi All,

I have a program that takes an XML file(has DTD and XML in the same file) as input. After parsing it, the output is written into a specified file. The output has first few lines of the DTD and the entire XML part, but is not having the ELEMENT and ATTLIST lines of the DTD.

My code runs like this:

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

dbf.setValidating(true);

DocumentBuilder db = dbf.newDocumentBuilder();

Document doc = db.newDocument();

db.setErrorHandler(new CustomErrorHandler());

doc = db.parse(inFile);

XmlDocumentxDoc = (XmlDocument) doc;

xDoc.write(new PrintWriter(fos));

TIA,

sri

[718 byte] By [thotha3] at [2007-9-26 2:34:46]
# 1

The standard parsers don't seem to do a very good job with DTDs. I've used a package at

http://www.wutka.com/dtdparser.html

to build DTDs. I haven't found a better way to get an internal DTD into an XML document than to separately convert both to String and manually insert the DTD (with appropriate DOCTYPE, etc.) into the XML.

zaneparks at 2007-6-29 9:59:58 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...