/** * Parses the document in a pull parsing fashion. * * @param complete True if the pull parser should parse the remaining document completely. * @return True if there is more document to parse. * @exception XNIException Any XNI exception, possibly wrapping another exception. * @exception IOException An IO exception from the parser, possibly from a byte stream or * character stream supplied by the parser. * @see #setInputSource */ public boolean parse(boolean complete) throws XNIException, IOException { try { boolean more = fDocumentScanner.scanDocument(complete); if (!more) { cleanup(); } return more; } catch (XNIException e) { cleanup(); throw e; } catch (IOException e) { cleanup(); throw e; } } // parse(boolean):boolean
/** * If the application decides to terminate parsing before the xml document is fully parsed, the * application should call this method to free any resource allocated during parsing. For example, * close all opened streams. */ public void cleanup() { fDocumentScanner.cleanup(fCloseStream); } // cleanup()
/** * <font color="red">EXPERIMENTAL: may change in next release</font><br> * Immediately evaluates an input source and add the new content (e.g. the output written by an * embedded script). * * @param inputSource The new input source to start scanning. * @see #pushInputSource(XMLInputSource) */ public void evaluateInputSource(XMLInputSource inputSource) { fDocumentScanner.evaluateInputSource(inputSource); } // evaluateInputSource(XMLInputSource)
/** * Sets the input source for the document to parse. * * @param inputSource The document's input source. * @exception XMLConfigurationException Thrown if there is a configuration error when initializing * the parser. * @exception IOException Thrown on I/O error. * @see #parse(boolean) */ public void setInputSource(XMLInputSource inputSource) throws XMLConfigurationException, IOException { reset(); fCloseStream = inputSource.getByteStream() == null && inputSource.getCharacterStream() == null; fDocumentScanner.setInputSource(inputSource); } // setInputSource(XMLInputSource)
/** * Pushes an input source onto the current entity stack. This enables the scanner to transparently * scan new content (e.g. the output written by an embedded script). At the end of the current * entity, the scanner returns where it left off at the time this entity source was pushed. * * <p><strong>Hint:</strong> To use this feature to insert the output of <SCRIPT> tags, * remember to buffer the <em>entire</em> output of the processed instructions before pushing a * new input source. Otherwise, events may appear out of sequence. * * @param inputSource The new input source to start scanning. * @see #evaluateInputSource(XMLInputSource) */ public void pushInputSource(XMLInputSource inputSource) { fDocumentScanner.pushInputSource(inputSource); } // pushInputSource(XMLInputSource)