protected void serializeDocType ( DocumentType node , boolean bStart ) throws SAXException { // The DocType and internalSubset can not be modified in DOM and is // considered to be well-formed as the outcome of successful parsing. String docTypeName = node . getNodeName ( ) ; String publicId = node . getPublicId ( ) ; String systemId = node . getSystemId ( ) ; String internalSubset = node . getInternalSubset ( ) ; //DocumentType nodes are never passed to the filter if ( internalSubset != null && ! "" . equals ( internalSubset ) ) { if ( bStart ) { try { // The Serializer does not provide a way to write out the // DOCTYPE internal subset via an event call, so we write it // out here. Writer writer = fSerializer . getWriter ( ) ; StringBuffer dtd = new StringBuffer ( ) ; dtd . append ( "<!DOCTYPE " ) ; dtd . append ( docTypeName ) ; if ( null != publicId ) { dtd . append ( " PUBLIC \"" ) ; dtd . append ( publicId ) ; dtd . append ( ' ' ) ; } if ( null != systemId ) { if ( null == publicId ) { dtd . append ( " SYSTEM \"" ) ; } else { dtd . append ( " \"" ) ; } dtd . append ( systemId ) ; dtd . append ( ' ' ) ; } dtd . append ( " [ " ) ; dtd . append ( fNewLine ) ; dtd . append ( internalSubset ) ; dtd . append ( "]>" ) ; dtd . append ( new String ( fNewLine ) ) ; writer . write ( dtd . toString ( ) ) ; writer . flush ( ) ; } catch ( IOException e ) { throw new SAXException ( Utils . messages . createMessage ( MsgKey . ER_WRITING_INTERNAL_SUBSET , null ) , e ) ; } } // else if !bStart do nothing } else { if ( bStart ) { if ( fLexicalHandler != null ) { fLexicalHandler . startDTD ( docTypeName , publicId , systemId ) ; } } else { if ( fLexicalHandler != null ) { fLexicalHandler . endDTD ( ) ; } } } }
Serializes a Document Type Node .