@Throws(XMLStreamException::class) operator fun next(): Int { log.fine("next()") if (event === START_DOCUMENT) { event = javax.xml.stream.XMLStreamConstants.START_ELEMENT elementIndex.currentElement = parser.getDocument().getBody().getElement() } else if (event === javax.xml.stream.XMLStreamConstants.START_ELEMENT) { elementIndex.index = 0 event = nextInElement(false) } else if (event === ATTRIBUTE) { elementIndex.index = 0 event = nextInElement(false) } else if (event === CHARACTERS) { elementIndex.index++ event = nextInElement(false) } else if (event === SPACE) { elementIndex.index++ event = nextInElement(false) } else if (event === ENTITY_REFERENCE) { elementIndex.index++ event = nextInElement(false) } else if (event === PROCESSING_INSTRUCTION) { elementIndex.index++ event = nextInElement(false) } else if (event === javax.xml.stream.XMLStreamConstants.END_ELEMENT) { if (parents.isEmpty()) { event = END_DOCUMENT } else { elementIndex = parents.pop() elementIndex.index++ event = nextInElement(false) } } else if (event === END_DOCUMENT) { throw XMLStreamException("End of coument reached!") } else { throw XMLStreamException("Invalid event state!") } log.log(Level.FINE, "next(): {0}", event) return event }
Get next parsing event - a processor may return all contiguous character data in a single chunk , or it may split it into several chunks . If the property javax.xml.stream.isCoalescing is set to true element content must be coalesced and only one CHARACTERS event must be returned for contiguous element content or CDATA Sections . By default entity references must be expanded and reported transparently to the application . An exception will be thrown if an entity reference can not be expanded . If element content is empty ( i.e . content is `` '' ) then no CHARACTERS event will be reported . < p > This method marks the current element and index using the elementIndex structure . Besides a queue of parents element index is maintained to cross over all element hierarchy. < /p > < p > The WbXMLStreamReader only manages the following states : < /p > < ul > < li > START_DOCUMENT < /li > < li > PROCESSING_INSTRUCTION < /li > < li > START_ELEMENT < /li > < li > ATTRIBUTE < /li > < lI > CHARACTERS < /li > < li > END_ELEMENT < /li > < li > SPACE < /li > < li > END_DOCUMENT < /li > < li > ENTITY_REFERENCE < /li > < /ul > < p > Therefore the following element does no matter in this stream reader : < /p > < ul > < li > CDATA ( CHARACTERS are used always ) . < /li > < li > COMMENT ( no comments in WBXML ) . < /li > < li > DTD ( no DTD section ) < /li > < li > ENTITY_DECLARATION < /li > < li > NAMESPACE < /li > < li > NOTATION DECLARATION < /li > < /ul >