/** * Finish processing an element. * * @param originalUri the URI. * @param localName the local name. * @param qName the qName. * @throws SAXException if there is a parsing error. */ public final void endElement( final String originalUri, final String localName, final String qName ) throws SAXException { final String defaultNamespace = namespaces.pop(); final String uri; if ( ( originalUri == null || "".equals( originalUri ) ) && defaultNamespace != null ) { uri = defaultNamespace; } else { uri = originalUri; } final XmlReadHandler currentHandler = getCurrentHandler(); currentHandler.endElement( uri, localName ); }
/** * Process character data. * * @param ch the character buffer. * @param start the start index. * @param length the length of the character data. * @throws SAXException if there is a parsing error. */ public void characters( final char[] ch, final int start, final int length ) throws SAXException { try { getCurrentHandler().characters( ch, start, length ); } catch ( SAXException se ) { throw se; } catch ( Exception e ) { throw new ParseException ( "Failed at handling character data", e, getDocumentLocator() ); } }
/** * Hand control back to the previous handler. * * @param tagName the tagname. * @param uri the namespace uri of the current tag. * @throws SAXException if there is a problem with the parser. */ public void unwind( final String uri, final String tagName ) throws SAXException { // remove current handler from stack .. this.currentHandlers.pop(); if ( this.currentHandlers.isEmpty() && !this.outerScopes.isEmpty() ) { // if empty, but "recurse" had been called, then restore the old handler stack .. // but do not end the recursed element .. this.currentHandlers = this.outerScopes.pop(); } else if ( !this.currentHandlers.isEmpty() ) { // if there are some handlers open, close them too (these handlers must be delegates).. getCurrentHandler().endElement( uri, tagName ); } }
final XmlReadHandler currentHandler = getCurrentHandler(); currentHandler.startElement( uri, localName, wrapAttributes( new FixNamespaceUriAttributes( uri, attributes ) ) );