B
bill turner
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>
DocumentBuilderFactory builderFactory
= DocumentBuilderFactory.newInstance();
builderFactory.setValidating(true);
DocumentBuilder builder = builderFactory.newDocumentBuilder();
DOMImplementation impl = builder.getDOMImplementation();
//DocumentType docType =impl.createDocumentType("trapbatch",
"","trapmonkey.dtd");
DocumentType docType = impl.createDocumentType("trapbatch",null,
"trapmonkey.dtd");
//doc = impl.createDocument("", "trapbatch", docType);
doc = impl.createDocument(null, "trapbatch", docType);
rootElement = doc.getDocumentElement();
doc.insertBefore(doc.createComment("a good rule of thumb is to use
child elements rather than attributes if the information feels like
data"), rootElement);
rootElement.appendChild(doc.createComment("enterpriseSpecfic Traps"));
rootElement.appendChild(doc.createComment("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.createElement("trap");
trapElement.setAttribute("repeat", trap.getRepeat());
trapElement.setAttribute("delayInMillis",trap.getDelayInMilliseconds());
rootElement.appendChild(trapElement);
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>
DocumentBuilderFactory builderFactory
= DocumentBuilderFactory.newInstance();
builderFactory.setValidating(true);
DocumentBuilder builder = builderFactory.newDocumentBuilder();
DOMImplementation impl = builder.getDOMImplementation();
//DocumentType docType =impl.createDocumentType("trapbatch",
"","trapmonkey.dtd");
DocumentType docType = impl.createDocumentType("trapbatch",null,
"trapmonkey.dtd");
//doc = impl.createDocument("", "trapbatch", docType);
doc = impl.createDocument(null, "trapbatch", docType);
rootElement = doc.getDocumentElement();
doc.insertBefore(doc.createComment("a good rule of thumb is to use
child elements rather than attributes if the information feels like
data"), rootElement);
rootElement.appendChild(doc.createComment("enterpriseSpecfic Traps"));
rootElement.appendChild(doc.createComment("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.createElement("trap");
trapElement.setAttribute("repeat", trap.getRepeat());
trapElement.setAttribute("delayInMillis",trap.getDelayInMilliseconds());
rootElement.appendChild(trapElement);