/** * Consumes all StAX events and passes them on to the content handler */ public void parse(XMLEventReader xmlReader) throws XMLStreamException, SAXException { while (xmlReader.hasNext()) { XMLEvent e = xmlReader.nextEvent(); if (e.isStartDocument()) handler.startDocument(); else if (e.isEndDocument()) handler.endDocument(); else if (e.isStartElement()) emitSE(e.asStartElement()); else if (e.isEndElement()) emitEE(e.asEndElement()); else if (e.isProcessingInstruction()) emitPi((ProcessingInstruction) e); else if (e.isCharacters()) emitChars(e.asCharacters()); else if (e.isAttribute()) emitAttr((Attribute) e); else if (e.isEntityReference()) emitEnt((EntityDeclaration) e); else if (e.isNamespace()) emitNS((Namespace) e); else if (e instanceof Comment) emitComment((Comment) e); else if (e instanceof DTD) emitDTD((DTD) e); else { //System.err.println("Unknown / unhandled event type " + e); //throw new SAXException("Unknown / unhandled event type " + e); } } }
/** * Consumes all StAX events and passes them on to the content handler */ public void parse(XMLEventReader xmlReader) throws XMLStreamException, SAXException { while (xmlReader.hasNext()) { XMLEvent e = xmlReader.nextEvent(); if (e.isStartDocument()) handler.startDocument(); else if (e.isEndDocument()) handler.endDocument(); else if (e.isStartElement()) emitSE(e.asStartElement()); else if (e.isEndElement()) emitEE(e.asEndElement()); else if (e.isProcessingInstruction()) emitPi((ProcessingInstruction) e); else if (e.isCharacters()) emitChars(e.asCharacters()); else if (e.isAttribute()) emitAttr((Attribute) e); else if (e.isEntityReference()) emitEnt((EntityDeclaration) e); else if (e.isNamespace()) emitNS((Namespace) e); else if (e instanceof Comment) emitComment((Comment) e); else if (e instanceof DTD) emitDTD((DTD) e); else { //System.err.println("Unknown / unhandled event type " + e); //throw new SAXException("Unknown / unhandled event type " + e); } } }