[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.
Thanks,
Bruce
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE newsfeed SYSTEM "newsfeed.dtd">
<newsfeed>
    <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
      </item>
      Bla bla bla more items
</channel>
</newsfeed>
      private void writeDoc(String fileName, Document doc) throws IOException {
             //send revised document to outputstream
             FileOutputStream fos = new FileOutputStream(fileName);
             XMLOutputter xmlout = new XMLOutputter("   ",true);
             xmlout.setTextNormalize(true);
            try
            {
             DocType doctype = doc.getDocType();
             xmlout.output(doctype,fos);
            }
             catch(NullPointerException npe){System.out.println("Holy Cow, 
no DTD!");}
             xmlout.output(doc, fos);
             fos.close();
      }
    
    
More information about the jdom-interest
mailing list