@ Override public void startElement ( String namespaceURI , String localName , String qName , Attributes atts ) throws SAXException { try { if ( XHTML_NS . equals ( namespaceURI ) ) { if ( "meta" . equals ( localName ) && ( ( atts . getIndex ( "" , "http-equiv" ) != - 1 ) || ( atts . getIndex ( "" , "httpequiv" ) != - 1 ) ) ) { return ; } // start and element name this . writer . write ( ' ' ) ; this . writer . write ( localName ) ; // attributes int length = atts . getLength ( ) ; boolean langPrinted = false ; for ( int i = 0 ; i < length ; i ++ ) { String ns = atts . getURI ( i ) ; String name = null ; if ( "" . equals ( ns ) ) { name = atts . getLocalName ( i ) ; } else if ( "http://www.w3.org/XML/1998/namespace" . equals ( ns ) && "lang" . equals ( atts . getLocalName ( i ) ) ) { name = "lang" ; } if ( name != null && ! ( langPrinted && "lang" . equals ( name ) ) ) { this . writer . write ( ' ' ) ; this . writer . write ( name ) ; if ( "lang" . equals ( name ) ) { langPrinted = true ; } if ( Arrays . binarySearch ( booleanAttributes , name ) < 0 ) { // write value, escape certain characters this . writer . write ( "=\"" ) ; String value = atts . getValue ( i ) ; for ( int j = 0 ; j < value . length ( ) ; j ++ ) { char c = value . charAt ( j ) ; switch ( c ) { case ' ' : this . writer . write ( "&lt;" ) ; break ; case ' ' : this . writer . write ( "&gt;" ) ; break ; case ' ' : this . writer . write ( "&amp;" ) ; break ; case ' ' : this . writer . write ( "&quot;" ) ; break ; default : this . writer . write ( c ) ; } } this . writer . write ( ' ' ) ; } } } // close this . writer . write ( ' ' ) ; if ( emitMeta && "head" . equals ( localName ) ) { this . writer . write ( "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" ) ; this . writer . write ( encoding ) ; this . writer . write ( "\">" ) ; } } } catch ( IOException ioe ) { throw ( SAXException ) new SAXException ( ioe ) . initCause ( ioe ) ; } }
Writes a start tag if the element is an XHTML element .