@Override public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { String tagName = localName.toUpperCase(Locale.ENGLISH); // make sure that this tag occurs in the proper context if(!elements.peek().isAllowed(tagName)) throw new SAXException(tagName+" is not allowed inside "+tagNames.peek()); Checker next = CHECKERS.get(tagName); if(next==null) next = ALL_ALLOWED; elements.push(next); tagNames.push(tagName); super.startElement(uri, localName, qName, atts); }
@Override public void endElement(String uri, String localName, String qName) throws SAXException { elements.pop(); tagNames.pop(); super.endElement(uri, localName, qName); }
@Override public void startDocument() throws SAXException { super.startDocument(); }
@Override public void startPrefixMapping(String prefix, String uri) throws SAXException { super.startPrefixMapping(prefix.intern(), uri.intern()); } };
lastOutputNodeType = Node.TEXT_NODE; super.characters(ch, start, length);
@Override public void endElement(String uri, String localName, String qName) throws SAXException { if (inAddress) { super.characters(newAddress.toCharArray(),0,newAddress.length()); } inAddress = false; super.endElement(uri, localName, qName); } };
@Override public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { super.ignorableWhitespace(ch, start, length); }
@Override public void endDocument() throws SAXException { super.endDocument(); if ( autoFlush ) { try { flush(); } catch ( IOException e) {} } }
@Override public void processingInstruction(String target, String data) throws SAXException { try { indent(); writer.write("<?"); writer.write(target); writer.write(" "); writer.write(data); writer.write("?>"); writePrintln(); lastOutputNodeType = Node.PROCESSING_INSTRUCTION_NODE; super.processingInstruction(target, data); } catch (IOException e) { handleException(e); } }
/** * <i>[SAX ContentHandler interface support]</i> Processes a * start of document event. * <p> * This implementation creates a new JDOM document builder and * marks the current result as "under construction".</p> * * @throws SAXException if any error occurred while creating * the document builder. */ @Override public void startDocument() throws SAXException { this.startDocumentReceived = true; // Reset any previously set result. setResult(null); // Create the actual JDOM document builder and register it as // ContentHandler on the superclass (XMLFilterImpl): this // implementation will take care of propagating the LexicalHandler // events. this.saxHandler = new FragmentHandler(getFactory()); super.setContentHandler(this.saxHandler); // And propagate event. super.startDocument(); }
@Override public void setDocumentLocator(Locator locator) { super.setDocumentLocator(locator); }
@Override public void startPrefixMapping(String prefix, String uri) throws SAXException { if ( namespacesMap == null ) { namespacesMap = new HashMap<>(); } namespacesMap.put(prefix, uri); super.startPrefixMapping(prefix, uri); }
/** * Write character data. * * Pass the event on down the filter chain for further processing. * * @param ch The array of characters to write. * @param start The starting position in the array. * @param len The number of characters to write. * @exception org.xml.sax.SAXException If there is an error * writing the characters, or if a handler further down * the filter chain raises an exception. * @see org.xml.sax.ContentHandler#characters(char[], int, int) */ public void characters (char ch[], int start, int len) throws SAXException { try { if (!startTagIsClosed) { write('>'); startTagIsClosed = true; } writeEsc(ch, start, len, false); super.characters(ch, start, len); } catch( IOException e ) { throw new SAXException(e); } }
/** * Write ignorable whitespace. * * Pass the event on down the filter chain for further processing. * * @param ch The array of characters to write. * @param start The starting position in the array. * @param length The number of characters to write. * @exception org.xml.sax.SAXException If there is an error * writing the whitespace, or if a handler further down * the filter chain raises an exception. * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int) */ public void ignorableWhitespace (char ch[], int start, int length) throws SAXException { try { writeEsc(ch, start, length, false); super.ignorableWhitespace(ch, start, length); } catch( IOException e ) { throw new SAXException(e); } }
/** * Write a newline at the end of the document. * * Pass the event on down the filter chain for further processing. * * @exception org.xml.sax.SAXException If there is an error * writing the newline, or if a handler further down * the filter chain raises an exception. * @see org.xml.sax.ContentHandler#endDocument() */ public void endDocument () throws SAXException { try { super.endDocument(); flush(); } catch( IOException e ) { throw new SAXException(e); } }
write('\n'); super.processingInstruction(target, data); } catch( IOException e ) { throw new SAXException(e);
@Override public void setDocumentLocator(Locator locator) { super.setDocumentLocator(locator); this.locator = locator; }
/** * be able to handle no namespace or older namespace */ @Override public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { if ("".equals(uri) || CacheXml.GEMFIRE_NAMESPACE.equals(uri)) { uri = CacheXml.GEODE_NAMESPACE; } super.startElement(uri, localName, qName, atts); }
startTagIsClosed = true; super.endElement(uri, localName, qName);
@Override public void startDocument() throws SAXException { try { writeDeclaration(); super.startDocument(); } catch (IOException e) { handleException(e); } }