[jdom-interest] No doctype found

Bruce Altner baltner at hq.nasa.gov
Wed Aug 7 11:03:44 PDT 2002

I just realized, after using an application for many months, that my 
writeDoc method was dropping the DOCTYPE declaration.
So I installed what I thought was the right solution but apparently 
doc.getDocType() is not finding it and returns null.
Can anyone tell me why, looking at the snippets below? Version jdom-beta8.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE newsfeed SYSTEM "newsfeed.dtd">
    <channel id="1" name="Code U Newsfeed" url="http://whatever.gov/">
       <item ID="116">
          <title>Research Announcement: Research Opportunities in Physical 
Sciences bla bla bla</title>
	bla bla bla more elements
      Bla bla bla more items

      private void writeDoc(String fileName, Document doc) throws IOException {
             //send revised document to outputstream
             FileOutputStream fos = new FileOutputStream(fileName);
             XMLOutputter xmlout = new XMLOutputter("   ",true);
             DocType doctype = doc.getDocType();
             catch(NullPointerException npe){System.out.println("Holy Cow, 
no DTD!");}
             xmlout.output(doc, fos);

More information about the jdom-interest mailing list