_printer.unindent(); state = getElementState(); if (state.empty) { _printer.printText( "/>" ); } else { _printer.printText( "]]>" ); _printer.breakLine(); _printer.printText( "</" ); _printer.printText( state.rawName ); _printer.printText( '>' ); state.empty = false; if (isDocumentState()) _printer.flush();
String dtd = _printer.leaveDTD(); if (! _format.getOmitDocumentType()) { if (_docTypeSystemId != null) { _printer.printText( "<!DOCTYPE " ); _printer.printText( name ); if (_docTypePublicId != null) { _printer.printText( " PUBLIC " ); printDoctypeURL( _docTypePublicId ); if (_indenting) { _printer.breakLine(); for (int i = 0 ; i < 18 + name.length() ; ++i) _printer.printText( " " ); } else _printer.printText( " " ); printDoctypeURL( _docTypeSystemId ); } else { _printer.printText( " SYSTEM " ); printDoctypeURL( _docTypeSystemId ); _printer.printText( " [" ); printText( dtd, true, true ); _printer.printText( ']' ); _printer.printText( ">" ); _printer.breakLine(); } else if (dtd != null && dtd.length() > 0) { _printer.printText( "<!DOCTYPE " ); _printer.printText( name );
/** * Serializes a namespace attribute with the given prefix and value for URI. * In case prefix is empty will serialize default namespace declaration. * * @param prefix * @param uri * @exception IOException */ private void printNamespaceAttr(String prefix, String uri) throws IOException{ _printer.printSpace(); if (prefix == XMLSymbols.EMPTY_STRING) { if (DEBUG) { System.out.println("=>add xmlns=\""+uri+"\" declaration"); } _printer.printText( XMLSymbols.PREFIX_XMLNS ); } else { if (DEBUG) { System.out.println("=>add xmlns:"+prefix+"=\""+uri+"\" declaration"); } _printer.printText( "xmlns:"+prefix ); } _printer.printText( "=\"" ); printEscaped( uri ); _printer.printText( '"' ); }
public void elementDecl( String name, String model ) throws SAXException { try { _printer.enterDTD(); _printer.printText( "<!ELEMENT " ); _printer.printText( name ); _printer.printText( ' ' ); _printer.printText( model ); _printer.printText( '>' ); if ( _indenting ) _printer.breakLine(); } catch ( IOException except ) { throw new SAXException( except ); } }
public void ignorableWhitespace( char[] chars, int start, int length ) throws SAXException { int i; try { content(); // Print ignorable whitespaces only when indenting, after // all they are indentation. Cancel the indentation to // not indent twice. if ( _indenting ) { _printer.setThisIndent( 0 ); for ( i = start ; length-- > 0 ; ++i ) _printer.printText( chars[ i ] ); } } catch ( IOException except ) { throw new SAXException( except ); } }
_printer.printText( '>' ); _printer.breakLine(); _printer.printText( '<' ); if ( _xhtml ) _printer.printText( rawName.toLowerCase(Locale.ENGLISH) ); else _printer.printText( rawName ); _printer.indent(); _printer.printSpace(); name = attrs.getQName( i ).toLowerCase(Locale.ENGLISH); value = attrs.getValue( i ); _printer.printText( name ); _printer.printText( "=\"\"" ); } else { _printer.printText( name ); _printer.printText( "=\"" ); printEscaped( value ); _printer.printText( '"' ); _printer.printText( name ); else if ( HTMLdtd.isURI( rawName, name ) ) { _printer.printText( name ); _printer.printText( "=\"" ); _printer.printText( escapeURI( value ) ); _printer.printText( '"' );
/** * Serializes the DOM element using the previously specified * writer and output format. Throws an exception only if * an I/O exception occured while serializing. * * @param elem The element to serialize * @throws IOException An I/O exception occured while * serializing */ public void serialize( Element elem ) throws IOException { reset(); prepare(); serializeNode( elem ); _printer.flush(); if ( _printer.getException() != null ) throw _printer.getException(); }
_printer.printText("&"); _printer.printText(node.getNodeName()); _printer.printText(";"); String internal; _printer.enterDTD(); _docTypePublicId = docType.getPublicId(); _docTypeSystemId = docType.getSystemId(); internal = docType.getInternalSubset(); if ( internal != null && internal.length() > 0 ) _printer.printText( internal ); endDTD(); _printer.enterDTD(); _docTypePublicId = docTypePublicId; _docTypeSystemId = docTypeSystemId;
public void breakLine( boolean preserveSpace ) throws IOException { breakLine(); }
/** * Called at the end of the document to wrap it up. * Will flush the output stream and throw an exception * if any I/O error occured while serializing. * * @throws SAXException An I/O exception occured during * serializing */ public void endDocument() throws SAXException { try { // Print all the elements accumulated outside of // the root element. serializePreRoot(); // Flush the output, this is necessary for fStrBuffered output. _printer.flush(); } catch ( IOException except ) { throw new SAXException( except ); } }
/** * Called to serialize the document's DOCTYPE by the root element. * <p> * This method will check if it has not been called before ({@link #_started}), * will serialize the document type declaration, and will serialize all * pre-root comments and PIs that were accumulated in the document * (see {@link #serializePreRoot}). Pre-root will be serialized even if * this is not the first root element of the document. */ protected void startDocument( String rootTagName ) throws IOException { // Required to stop processing the DTD, even though the DTD // is not printed. _printer.leaveDTD(); _started = true; // Always serialize these, even if not te first root element. serializePreRoot(); }
public final void startDTD( String name, String publicId, String systemId ) throws SAXException { try { _printer.enterDTD(); _docTypePublicId = publicId; _docTypeSystemId = systemId; } catch ( IOException except ) { throw new SAXException( except ); } }
/** * Called by the root element to leave DTD mode and if any * DTD parts were printer, will return a string with their * textual content. */ public String leaveDTD() throws IOException { // Only works if we're going out of DTD mode. if ( _writer == _dtdWriter ) { flushLine( false ); _writer = _docWriter; return _dtdWriter.toString(); } else return null; }
} else { _indenting = false; _printer = new Printer( _writer, _format );
_printer.printText( '>' ); _printer.breakLine(); _printer.printText( '<' ); if ( _xhtml ) _printer.printText( rawName.toLowerCase(Locale.ENGLISH) ); else _printer.printText( rawName ); _printer.indent(); _printer.printSpace(); name = attrs.getQName( i ).toLowerCase(Locale.ENGLISH); value = attrs.getValue( i ); _printer.printText( name ); _printer.printText( "=\"\"" ); } else { _printer.printText( name ); _printer.printText( "=\"" ); printEscaped( value ); _printer.printText( '"' ); _printer.printText( name ); else if ( HTMLdtd.isURI( rawName, name ) ) { _printer.printText( name ); _printer.printText( "=\"" ); _printer.printText( escapeURI( value ) ); _printer.printText( '"' );
public void elementDecl( String name, String model ) throws SAXException { try { _printer.enterDTD(); _printer.printText( "<!ELEMENT " ); _printer.printText( name ); _printer.printText( ' ' ); _printer.printText( model ); _printer.printText( '>' ); if ( _indenting ) _printer.breakLine(); } catch ( IOException except ) { throw new SAXException( except ); } }
/** * Serializes the DOM document fragmnt using the previously specified * writer and output format. Throws an exception only if * an I/O exception occured while serializing. * * @param elem The element to serialize * @throws IOException An I/O exception occured while * serializing */ public void serialize( DocumentFragment frag ) throws IOException { reset(); prepare(); serializeNode( frag ); _printer.flush(); if ( _printer.getException() != null ) throw _printer.getException(); }