This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes How to transform DTD with JAXP Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "How to transform DTD with JAXP" Watch "How to transform DTD with JAXP" New topic
Author

How to transform DTD with JAXP

Juhan Voolaid
Ranch Hand

Joined: Nov 18, 2003
Posts: 179
Hi

I use JAXP and dom with my xml file to read data, change it and then write the data back to xml file. Problem is that in my new xml file DTD specification is gone. Shortly, from the second line in my xml file that row is missing:
<!DOCTYPE scores SYSTEM "scores.dtd">

this is how i write data(Document document) to my xml file:


I don't know what should i do.

[ August 19, 2004: Message edited by: Juhan Voolaid ]
[ August 21, 2004: Message edited by: Juhan Voolaid ]
Juhan Voolaid
Ranch Hand

Joined: Nov 18, 2003
Posts: 179
OK, found it. If anyone is interested then this should be added to transformer:
transformer.setOutputProperty(javax.xml.transform.OutputKeys.DOCTYPE_SYSTEM, dtd);
where dtd is string "dtdFile.dtd"
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How to transform DTD with JAXP
 
Similar Threads
Avoiding XML escaped values (i.e. &gt)
Writing XML File via Java Program
Return type recomendation
XML on the fly using servlets
Getting length(no of bytes) of Dom document which is in memory