IntelliJ Java IDE
The moose likes XML and Related Technologies and the fly likes Can I create DOCTYPE  element ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "Can I create DOCTYPE  element ?" Watch "Can I create DOCTYPE  element ?" New topic
Author

Can I create DOCTYPE element ?

Tom John
Greenhorn

Joined: Jun 29, 2001
Posts: 10
I'm generating an xml document from scratch using a DOM created with user input. I can't find a way to create the DOCTYPE element. Any suggestions?
SAFROLE M3
Greenhorn

Joined: Jun 28, 2001
Posts: 18
I dont think there is a method you can call to set the DOCTYPE using DOM, but there is no need to. In your application, you can create an in-memory DOM by reading a text file that acts as a template for you XML document. In other words, your text file would contain the bare bones for the XML document, including the DOCTYPE, such as...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sample SYSTEM "dt.dtd">
<root>
</root>
So, after you read the text file, you have a DOM representation of your basic XML document, including the DOCTYPE, and you can add nodes to the document from the user input.
Hope that helps you,
SAF
Tom John
Greenhorn

Joined: Jun 29, 2001
Posts: 10
Thanks SAF, that worked out great
 
IntelliJ Java IDE
 
subject: Can I create DOCTYPE element ?
 
Threads others viewed
JavaRanch DTD Exam Question 3
Sample DTD Question #3
question on mock exam
Is this a valid DTD ?
question on mock exam
IntelliJ Java IDE