setDoctype() does the job !
/**
* Gets the
xml
*
*
@return the xml or "no
valid document"
* @exception
Standard exception "Exception" will be thrown
*
*/
public String GetXml()
{
if
(null == document)
{
return "no valid document, cannot
serialize DOM tree";
}
OutputFormat oformat = new
OutputFormat(document);
oformat.setDoctype(null,
document.getDoctype().getSystemId());
oformat.setLineWidth(80);
oformat.setIndent(2);
oformat.setLineSeparator("\r\n");
oformat.setPreserveSpace(false);
oformat.setOmitComments(false);
oformat.setOmitDocumentType(false);
oformat.setOmitXMLDeclaration(false);
oformat.setEncoding(encType);
oformat.setVersion("1.0");
oformat.setStandalone(true);
oformat.setIndenting(true);
oformat.setPreserveEmptyAttributes(true);
StringWriter
stringOut = new StringWriter();
try
{
XMLSerializer
serial = new XMLSerializer(stringOut,
oformat);
serial.asDOMSerializer();
serial.serialize(document);
}
catch (Exception e)
{
e.printStackTrace(System.err);
}
return stringOut.toString();
}
> -----Urspr�ngliche
Nachricht-----
> Von: Hand, Brian [mailto:[EMAIL PROTECTED]]
>
Gesendet: Mittwoch, 3. April 2002 23:45
> An:
'[EMAIL PROTECTED]'
> Betreff: Setting a DOCTYPE Declaration
through DocumentType
> for a brand
> ne w
document
>
>
> Hi all,
>
> Being somewhat a newbie
to Xerces I would like a create a
> document (via a
> save function)
and I would like to set the <!DOCTYPE ....
> statement in the
>
document to be saved. I see that there are no setters in the
>
DocumentType
> interface and was just wondering if someone could offer
a
> quick snippet of
> code on how to set the <!DOCTYPE into the
generated document.
>
> BTW I am using the DOM API.
>
>
Thanks
> Brian
>
>
---------------------------------------------------------------------
> To
unsubscribe, e-mail: [EMAIL PROTECTED]
> For
additional commands, e-mail: [EMAIL PROTECTED]
>
