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 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 attributeDecl( String eName, String aName, String type, String valueDefault, String value ) throws SAXException { try { _printer.enterDTD(); _printer.printText( "<!ATTLIST " ); _printer.printText( eName ); _printer.printText( ' ' ); _printer.printText( aName ); _printer.printText( ' ' ); _printer.printText( type ); if ( valueDefault != null ) { _printer.printText( ' ' ); _printer.printText( valueDefault ); } if ( value != null ) { _printer.printText( " \"" ); printEscaped( value ); _printer.printText( '"' ); } _printer.printText( '>' ); if ( _indenting ) _printer.breakLine(); } catch ( IOException except ) { throw new SAXException( except ); } }
/** * Print a document type public or system identifier URL. * Encapsulates the URL in double quotes, escapes non-printing * characters and print it equivalent to {@link #printText}. * * @param url The document type url to print */ protected void printDoctypeURL( String url ) throws IOException { int i; _printer.printText( '"' ); for( i = 0 ; i < url.length() ; ++i ) { if ( url.charAt( i ) == '"' || url.charAt( i ) < 0x20 || url.charAt( i ) > 0x7F ) { _printer.printText( '%' ); _printer.printText( Integer.toHexString( url.charAt( i ) ) ); } else _printer.printText( url.charAt( i ) ); } _printer.printText( '"' ); }
/** * Print a document type public or system identifier URL. * Encapsulates the URL in double quotes, escapes non-printing * characters and print it equivalent to {@link #printText}. * * @param url The document type url to print */ protected void printDoctypeURL( String url ) throws IOException { int i; _printer.printText( '"' ); for( i = 0 ; i < url.length() ; ++i ) { if ( url.charAt( i ) == '"' || url.charAt( i ) < 0x20 || url.charAt( i ) > 0x7F ) { _printer.printText( '%' ); _printer.printText( Integer.toHexString( url.charAt( i ) ) ); } else _printer.printText( url.charAt( i ) ); } _printer.printText( '"' ); }
public void internalEntityDecl( String name, String value ) throws SAXException { try { _printer.enterDTD(); _printer.printText( "<!ENTITY " ); _printer.printText( name ); _printer.printText( " \"" ); printEscaped( value ); _printer.printText( "\">" ); if ( _indenting ) _printer.breakLine(); } catch ( IOException except ) { throw new SAXException( except ); } }
/** * 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 internalEntityDecl( String name, String value ) throws SAXException { try { _printer.enterDTD(); _printer.printText( "<!ENTITY " ); _printer.printText( name ); _printer.printText( " \"" ); printEscaped( value ); _printer.printText( "\">" ); if ( _indenting ) _printer.breakLine(); } catch ( IOException except ) { throw new SAXException( except ); } }
/** print text data */ protected void printXMLChar( int ch) throws IOException { if (ch == '\r') { printHex(ch); } else if ( ch == '<') { _printer.printText("<"); } else if (ch == '&') { _printer.printText("&"); } else if (ch == '>'){ // character sequence "]]>" can't appear in content, therefore // we should escape '>' _printer.printText(">"); } else if ( ch == '\n' || ch == '\t' || ( ch >= ' ' && _encodingInfo.isPrintable((char)ch))) { _printer.printText((char)ch); } else { printHex(ch); } }
/** print text data */ protected void printXMLChar( int ch) throws IOException { if (ch == '\r') { printHex(ch); } else if ( ch == '<') { _printer.printText("<"); } else if (ch == '&') { _printer.printText("&"); } else if (ch == '>'){ // character sequence "]]>" can't appear in content, therefore // we should escape '>' _printer.printText(">"); } else if ( ch == '\n' || ch == '\t' || ( ch >= ' ' && _encodingInfo.isPrintable((char)ch))) { _printer.printText((char)ch); } else { printHex(ch); } }
public void notationDecl( String name, String publicId, String systemId ) throws SAXException { try { _printer.enterDTD(); if ( publicId != null ) { _printer.printText( "<!NOTATION " ); _printer.printText( name ); _printer.printText( " PUBLIC " ); printDoctypeURL( publicId ); if ( systemId != null ) { _printer.printText( ' ' ); printDoctypeURL( systemId ); } } else { _printer.printText( "<!NOTATION " ); _printer.printText( name ); _printer.printText( " SYSTEM " ); printDoctypeURL( systemId ); } _printer.printText( '>' ); if ( _indenting ) _printer.breakLine(); } catch ( IOException except ) { throw new SAXException( except ); } }
protected final void printXMLChar( int ch ) throws IOException { if (ch == '\r' || ch == 0x0085 || ch == 0x2028) { printHex(ch); } else if ( ch == '<') { _printer.printText("<"); } else if (ch == '&') { _printer.printText("&"); } else if (ch == '>'){ // character sequence "]]>" can't appear in content, therefore // we should escape '>' _printer.printText(">"); } else if ( _encodingInfo.isPrintable((char)ch) && XML11Char.isXML11ValidLiteral(ch)) { _printer.printText((char)ch); } else { printHex(ch); } }
protected final void printXMLChar( int ch ) throws IOException { if (ch == '\r' || ch == 0x0085 || ch == 0x2028) { printHex(ch); } else if ( ch == '<') { _printer.printText("<"); } else if (ch == '&') { _printer.printText("&"); } else if (ch == '>'){ // character sequence "]]>" can't appear in content, therefore // we should escape '>' _printer.printText(">"); } else if ( _encodingInfo.isPrintable((char)ch) && XML11Char.isXML11ValidLiteral(ch)) { _printer.printText((char)ch); } else { printHex(ch); } }
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 ); } }
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 ); } }
protected void surrogates(int high, int low) throws IOException{ if (XMLChar.isHighSurrogate(high)) { if (!XMLChar.isLowSurrogate(low)) { //Invalid XML fatalError("The character '"+(char)low+"' is an invalid XML character"); } else { int supplemental = XMLChar.supplemental((char)high, (char)low); if (!XMLChar.isValid(supplemental)) { //Invalid XML fatalError("The character '"+(char)supplemental+"' is an invalid XML character"); } else { if (content().inCData ) { _printer.printText("]]>&#x"); _printer.printText(Integer.toHexString(supplemental)); _printer.printText(";<![CDATA["); } else { printHex(supplemental); } } } } else { fatalError("The character '"+(char)high+"' is an invalid XML character"); } }