I've searched the web and news groups. It seems others have had this
problem. Unfortunately, the solution seems to be exactly what I've
coded. If anybody can point out what is wrong, I'd truly appreciate
it. What I am trying to do is to write an xml file to a local disk
file. Everything else comes out just fine. However, the DOCTYPE node
is not created. I've tried a number of different things, including
specifying that I wanted a validating implementation, all to no avail.
Here is a snippet of the relative code:
<snippet>
DocumentBuilder Factory builderFactory
= DocumentBuilder Factory.newInst ance();
builderFactory. setValidating(t rue);
DocumentBuilder builder = builderFactory. newDocumentBuil der();
DOMImplementati on impl = builder.getDOMI mplementation() ;
//DocumentType docType =impl.createDoc umentType("trap batch",
"","trapmonkey. dtd");
DocumentType docType = impl.createDocu mentType("trapb atch",null,
"trapmonkey.dtd ");
//doc = impl.createDocu ment("", "trapbatch" , docType);
doc = impl.createDocu ment(null, "trapbatch" , docType);
rootElement = doc.getDocument Element();
doc.insertBefor e(doc.createCom ment("a good rule of thumb is to use
child elements rather than attributes if the information feels like
data"), rootElement);
rootElement.app endChild(doc.cr eateComment("en terpriseSpecfic Traps"));
rootElement.app endChild(doc.cr eateComment("if repeat attribute = 0,
the the delayInMillis attribute is meaningless. The The delayInMillis
attribute is defaulted by the application in all other situations"));
for (int i = 0; i < this.size(); i++)
{
trap = this.get(i);
trapElement = doc.createEleme nt("trap");
trapElement.set Attribute("repe at", trap.getRepeat( ));
trapElement.set Attribute("dela yInMillis",trap .getDelayInMill iseconds());
rootElement.app endChild(trapEl ement);
problem. Unfortunately, the solution seems to be exactly what I've
coded. If anybody can point out what is wrong, I'd truly appreciate
it. What I am trying to do is to write an xml file to a local disk
file. Everything else comes out just fine. However, the DOCTYPE node
is not created. I've tried a number of different things, including
specifying that I wanted a validating implementation, all to no avail.
Here is a snippet of the relative code:
<snippet>
DocumentBuilder Factory builderFactory
= DocumentBuilder Factory.newInst ance();
builderFactory. setValidating(t rue);
DocumentBuilder builder = builderFactory. newDocumentBuil der();
DOMImplementati on impl = builder.getDOMI mplementation() ;
//DocumentType docType =impl.createDoc umentType("trap batch",
"","trapmonkey. dtd");
DocumentType docType = impl.createDocu mentType("trapb atch",null,
"trapmonkey.dtd ");
//doc = impl.createDocu ment("", "trapbatch" , docType);
doc = impl.createDocu ment(null, "trapbatch" , docType);
rootElement = doc.getDocument Element();
doc.insertBefor e(doc.createCom ment("a good rule of thumb is to use
child elements rather than attributes if the information feels like
data"), rootElement);
rootElement.app endChild(doc.cr eateComment("en terpriseSpecfic Traps"));
rootElement.app endChild(doc.cr eateComment("if repeat attribute = 0,
the the delayInMillis attribute is meaningless. The The delayInMillis
attribute is defaulted by the application in all other situations"));
for (int i = 0; i < this.size(); i++)
{
trap = this.get(i);
trapElement = doc.createEleme nt("trap");
trapElement.set Attribute("repe at", trap.getRepeat( ));
trapElement.set Attribute("dela yInMillis",trap .getDelayInMill iseconds());
rootElement.app endChild(trapEl ement);
Comment