/*
*/
/*
* Copyright 2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This class is responsible for scanning XML document structure
* and content.
*
* This class has been modified as per the new design which is more suited to
* efficiently build pull parser. Lot of improvements have been done and
* the code has been added to support stax functionality/features.
*
* @author Neeraj Bajaj, Sun Microsystems
* @author K.Venugopal, Sun Microsystems
* @author Glenn Marcy, IBM
* @author Andy Clark, IBM
* @author Arnaud Le Hors, IBM
* @author Eric Ye, IBM
* @author Sunitha Reddy, Sun Microsystems
*
* Refer to the table in unit-test javax.xml.stream.XMLStreamReaderTest.SupportDTD for changes
* related to property SupportDTD.
* @author Joe Wang, Sun Microsystems
* @version $Id: XMLDocumentScannerImpl.java,v 1.17 2010-11-01 04:39:41 joehw Exp $
*/
public class XMLDocumentScannerImpl
extends XMLDocumentFragmentScannerImpl{
//
// Constants
//
// scanner states
/** Scanner state: XML declaration. */
/** Scanner state: prolog. */
/** Scanner state: trailing misc. */
/** Scanner state: DTD internal declarations. */
/** Scanner state: open DTD external subset. */
/** Scanner state: DTD external declarations. */
/** Scanner state: NO MORE ELEMENTS. */
// feature identifiers
/** Property identifier document scanner: */
/** Feature identifier: load external DTD. */
/** Feature identifier: load external DTD. */
// property identifiers
/** Property identifier: DTD scanner. */
// property identifier: ValidationManager
/** property identifier: NamespaceContext */
// recognized features and properties
/** Recognized features. */
};
/** Feature defaults. */
};
/** Recognized properties. */
};
/** Property defaults. */
null,
};
//
// Data((Boolean)propertyManager.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE)).booleanValue();
//
// properties
/** DTD scanner. */
/** Validation manager . */
//xxx: fValidationManager code needs to be added yet!
protected boolean fReadingDTD = false;
protected boolean fAddedListener = false;
// protected data
// other info
/** Doctype name. */
/** Doctype declaration public identifier. */
/** Doctype declaration system identifier. */
/** Namespace support. */
// features
/** Load external DTD. */
protected boolean fLoadExternalDTD = true;
// state
/** Seen doctype declaration. */
protected boolean fSeenDoctypeDecl;
protected boolean fScanEndElement;
//protected int fScannerLastState ;
// drivers
/** XML declaration driver. */
/** Prolog driver. */
/** DTD driver. */
/** Trailing miscellaneous section driver. */
protected boolean fSeenInternalSubset= false;
// temporary variables
/** Array of 3 strings. */
/** External subset source. */
/** A DTD Description. */
private final XMLDTDDescription fDTDDescription = new XMLDTDDescription(null, null, null, null, null);
/** String. */
//
// Constructors
//
/** Default constructor. */
//
// XMLDocumentScanner methods
//
/**
* Sets the input source.
*
* @param inputSource The input source.
*
* @throws IOException Thrown on i/o error.
*/
fEntityManager.setEntityHandler(this);
//this starts a new entity and sets the current entity to the document entity.
// fDocumentSystemId = fEntityManager.expandSystemId(inputSource.getSystemId());
} // setInputSource(XMLInputSource)
/**return the state of the scanner */
public int getScannetState(){
return fScannerState ;
}
super.reset(propertyManager);
// other settings
fDoctypeName = null;
fSeenDoctypeDecl = false;
// xerces features
fLoadExternalDTD = !((Boolean)propertyManager.getProperty(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.IGNORE_EXTERNAL_DTD)).booleanValue();
fSeenInternalSubset = false;
if(fDTDScanner != null){
}
fEndPos = 0;
fStartPos = 0;
}
}
/**
* Resets the component. The component can query the component manager
* about any features and properties that affect the operation of the
* component.
*
* @param componentManager The component manager.
*
* @throws SAXException Thrown by component on initialization error.
* For example, if a feature or property is
* required for the operation of the component, the
* component manager may throw a
* SAXNotRecognizedException or a
* SAXNotSupportedException.
*/
throws XMLConfigurationException {
super.reset(componentManager);
// other settings
fDoctypeName = null;
fSeenDoctypeDecl = false;
// xerces features
fSeenInternalSubset = false;
// xerces properties
try {
}
catch (XMLConfigurationException e) { }
if (fNamespaceContext == null) {
fNamespaceContext = new NamespaceSupport();
}
fEndPos = 0;
fStartPos = 0;
//fEntityScanner.registerListener((XMLBufferListener)componentManager.getProperty(DOCUMENT_SCANNER));
// setup driver
} // reset(XMLComponentManager)
/**
* Returns a list of feature identifiers that are recognized by
* this component. This method may return null if no features
* are recognized by this component.
*/
if (featureIds != null) {
}
return combinedFeatureIds;
} // getRecognizedFeatures():String[]
/**
* Sets the state of a feature. This method is called by the component
* manager any time after reset when a feature changes state.
* <p>
* <strong>Note:</strong> Components should silently ignore features
* that do not affect the operation of the component.
*
* @param featureId The feature identifier.
* @param state The state of the feature.
*
* @throws SAXNotRecognizedException The component should not throw
* this exception.
* @throws SAXNotSupportedException The component should not throw
* this exception.
*/
throws XMLConfigurationException {
// Xerces properties
return;
}
return;
}
}
} // setFeature(String,boolean)
/**
* Returns a list of property identifiers that are recognized by
* this component. This method may return null if no properties
* are recognized by this component.
*/
if (propertyIds != null) {
}
System.arraycopy(RECOGNIZED_PROPERTIES, 0, combinedPropertyIds, length, RECOGNIZED_PROPERTIES.length);
return combinedPropertyIds;
} // getRecognizedProperties():String[]
/**
* Sets the value of a property. This method is called by the component
* manager any time after reset when a property changes value.
* <p>
* <strong>Note:</strong> Components should silently ignore properties
* that do not affect the operation of the component.
*
* @param propertyId The property identifier.
* @param value The value of the property.
*
* @throws SAXNotRecognizedException The component should not throw
* this exception.
* @throws SAXNotSupportedException The component should not throw
* this exception.
*/
throws XMLConfigurationException {
// Xerces properties
}
}
}
return;
}
} // setProperty(String,Object)
/**
* Returns the default state for a feature, or null if this
* component does not want to report a default value for this
* feature.
*
* @param featureId The feature identifier.
*
* @since Xerces 2.2.0
*/
return FEATURE_DEFAULTS[i];
}
}
return super.getFeatureDefault(featureId);
} // getFeatureDefault(String):Boolean
/**
* Returns the default state for a property, or null if this
* component does not want to report a default value for this
* property.
*
* @param propertyId The property identifier.
*
* @since Xerces 2.2.0
*/
return PROPERTY_DEFAULTS[i];
}
}
return super.getPropertyDefault(propertyId);
} // getPropertyDefault(String):Object
//
// XMLEntityHandler methods
//
/**
* This method notifies of the start of an entity. The DTD has the
* pseudo-name of "[dtd]" parameter entity names start with '%'; and
* general entities are just specified by their name.
*
* @param name The name of the entity.
* @param identifier The resource identifier.
* @param encoding The auto-detected IANA encoding name of the entity
* stream. This value will be null in those situations
* where the entity encoding is not auto-detected (e.g.
* internal entities or a document entity that is
* parsed from a java.io.Reader).
*
* @throws XNIException Thrown by handler to signal an error.
*/
//register current document scanner as a listener for XMLEntityScanner
fEntityScanner.registerListener(this);
// prepare to look for a TextDecl if external general entity
// Don't do this if we're skipping the entity!
}
}
// call handler
/** comment this part.. LOCATOR problem.. */
}
} // startEntity(String,identifier,String)
/**
* This method notifies the end of an entity. The DTD has the pseudo-name
* of "[dtd]" parameter entity names start with '%'; and general entities
* are just specified by their name.
*
* @param name The name of the entity.
*
* @throws XNIException Thrown by handler to signal an error.
*/
//if fMarkupDepth has reached 0.
//and driver is fTrailingMiscDriver (which
//handles end of document in normal case)
//set the scanner state of SCANNER_STATE_TERMINATED
//set the scanner set to SCANNER_STATE_TERMINATED
} else{
//else we have reached the end of document prematurely
//so throw EOFException.
}
//this is taken care in wrapper which generates XNI callbacks, There are no next events
//if (fDocumentHandler != null) {
//fDocumentHandler.endDocument(null);
//}
}
} // endEntity(String)
return fDTDDecl;
}
return fDeclaredEncoding;
}
/** return the next state on the input
*
* @return int
*/
}
//getNamespaceContext
return fNamespaceContext ;
}
//
// Protected methods
//
// driver factory methods
/** Creates a content driver. */
return new ContentDriver();
} // createContentDriver():Driver
// scanning methods
/** Scans a doctype declaration. */
// spaces
if (!fEntityScanner.skipSpaces()) {
reportFatalError("MSG_SPACE_REQUIRED_BEFORE_ROOT_ELEMENT_TYPE_IN_DOCTYPEDECL",
null);
}
// root element name
if (fDoctypeName == null) {
}
// external id
if (fEntityScanner.skipSpaces()) {
scanExternalID(fStrings, false);
}
// Attempt to locate an external subset with an external subset resolver.
fDTDDescription.setValues(null, null, fEntityManager.getCurrentResourceIdentifier().getExpandedSystemId(), null);
}
// call handler
// NOTE: I don't like calling the doctypeDecl callback until
// end of the *full* doctype line (including internal
// subset) is parsed correctly but SAX2 requires that
// it knows the root element name and public and system
// identifier for the startDTD call. -Ac
if (fExternalSubsetSource == null) {
}
else {
fDocumentHandler.doctypeDecl(fDoctypeName, fExternalSubsetSource.getPublicId(), fExternalSubsetSource.getSystemId(), null);
}
}
// is there an internal subset?
boolean internalSubset = true;
internalSubset = false;
}
fMarkupDepth--;
}
return internalSubset;
} // scanDoctypeDecl():boolean
//
// Private methods
//
/** Set the scanner state after scanning DTD */
protected void setEndDTDScanState() {
fReadingDTD=false;
}
/** Returns the scanner state name. */
switch (state) {
case SCANNER_STATE_XML_DECL: return "SCANNER_STATE_XML_DECL";
case SCANNER_STATE_PROLOG: return "SCANNER_STATE_PROLOG";
case SCANNER_STATE_TRAILING_MISC: return "SCANNER_STATE_TRAILING_MISC";
case SCANNER_STATE_DTD_INTERNAL_DECLS: return "SCANNER_STATE_DTD_INTERNAL_DECLS";
case SCANNER_STATE_DTD_EXTERNAL: return "SCANNER_STATE_DTD_EXTERNAL";
case SCANNER_STATE_DTD_EXTERNAL_DECLS: return "SCANNER_STATE_DTD_EXTERNAL_DECLS";
}
return super.getScannerStateName(state);
} // getScannerStateName(int):String
//
// Classes
//
/**
* Driver to handle XMLDecl scanning.
*
* This class has been modified as per the new design which is more suited to
* efficiently build pull parser. Lots of performance improvements have been done and
* the code has been added to support stax functionality/features.
*
* @author Neeraj Bajaj, Sun Microsystems.
*
* @author Andy Clark, IBM
*/
protected final class XMLDeclDriver
implements Driver {
//
// Driver methods
//
if(DEBUG_NEXT){
}
// next driver is prolog regardless of whether there
// is an XMLDecl in this document
//System.out.println("fEntityScanner = " + fEntityScanner);
// scan XMLDecl
try {
fMarkupDepth++;
// NOTE: special case where document starts with a PI
// whose name starts with "xml" (e.g. "xmlfoo")
}
String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
//this function should fill the data.. and set the fEvent object to this event.
fContentBuffer.clear() ;
//REVISIT:where else we can set this value to 'true'
//return PI event since PI was encountered
return XMLEvent.PROCESSING_INSTRUCTION ;
}
// standard XML declaration
else {
scanXMLDeclOrTextDecl(false);
//REVISIT:where else we can set this value to 'true'
return XMLEvent.START_DOCUMENT;
}
} else{
//REVISIT:where else we can set this value to 'true'
//In both case return the START_DOCUMENT. ony difference is that first block will
//cosume the XML declaration if any.
return XMLEvent.START_DOCUMENT;
}
//START_OF_THE_DOCUMENT
}
// premature end of file
catch (EOFException e) {
return -1;
//throw e;
}
}
} // class XMLDeclDriver
/**
* Driver to handle prolog scanning.
*
* @author Andy Clark, IBM
*/
protected final class PrologDriver
implements Driver {
/**
*
* Internally XML document is divided into several states. Each state represents
* a sections of XML document. When this functions returns normally, it has read
* the section of XML document and returns the state corresponding to section of
* document which has been read. For optimizations, a particular driver
* can read ahead of the section of document (state returned) just read and
* can maintain a different internal state.
*
* @return state representing the section of document just read.
*
* @throws IOException Thrown on i/o error.
* @throws XNIException Thrown on parse error.
*/
//System.out.println("here in next");
if(DEBUG_NEXT){
}
try {
do {
switch (fScannerState) {
case SCANNER_STATE_PROLOG: {
} else {
}
break;
}
case SCANNER_STATE_START_OF_MARKUP: {
fMarkupDepth++;
reportFatalError("InvalidCommentStart",
null);
}
}
fReadingDTD=true;
fDTDDecl = new XMLStringBuffer();
} else {
reportFatalError("MarkupNotRecognizedInProlog",
null);
}
//from now onwards this would be handled by fContentDriver,in the same next() call
return fContentDriver.next();
} else {
reportFatalError("MarkupNotRecognizedInProlog",
null);
}
break;
}
}
switch(fScannerState){
/**
//this part is handled by FragmentContentHandler
case SCANNER_STATE_ROOT_ELEMENT: {
//we have read '<' and beginning of reading the start element tag
setScannerState(SCANNER_STATE_START_ELEMENT_TAG);
setDriver(fContentDriver);
//from now onwards this would be handled by fContentDriver,in the same next() call
return fContentDriver.next();
}
*/
case SCANNER_STATE_COMMENT: {
//this function fills the data..
scanComment();
//setScannerState(SCANNER_STATE_PROLOG);
//break;
}
case SCANNER_STATE_PI: {
fContentBuffer.clear() ;
return XMLEvent.PROCESSING_INSTRUCTION;
}
case SCANNER_STATE_DOCTYPE: {
if (fDisallowDoctype) {
}
if (fSeenDoctypeDecl) {
}
fSeenDoctypeDecl = true;
// scanDoctypeDecl() sends XNI doctypeDecl event that
// in SAX is converted to startDTD() event.
if (scanDoctypeDecl(fSupportDTD)) {
//allow parsing of entity decls to continue in order to stay well-formed
fSeenInternalSubset = true;
if(fDTDDriver == null){
fDTDDriver = new DTDDriver();
}
//always return DTD event, the event however, will not contain any entities
return fDTDDriver.next();
}
if(fSeenDoctypeDecl){
}
fReadingDTD = false;
}
// handle external subset
if (fDoctypeSystemId != null) {
if (((fValidation || fLoadExternalDTD)
if (fSupportDTD) {
} else {
}
if(fDTDDriver == null) {
fDTDDriver = new DTDDriver();
}
return fDTDDriver.next();
}
}
else if (fExternalSubsetSource != null) {
if (((fValidation || fLoadExternalDTD)
// This handles the case of a DOCTYPE that had neither an internal subset or an external subset.
if (fSupportDTD)
else
if(fDTDDriver == null)
fDTDDriver = new DTDDriver();
return fDTDDriver.next();
}
}
// Send endDTD() call if:
// a) systemId is null or if an external subset resolver could not locate an external subset.
// b) "load-external-dtd" and validation are false
// c) DTD grammar is cached
// in XNI this results in 3 events: doctypeDecl, startDTD, endDTD
// in SAX this results in 2 events: startDTD, endDTD
if (fDTDScanner != null) {
}
}
case SCANNER_STATE_CONTENT: {
}
case SCANNER_STATE_REFERENCE: {
}
/**
* if (complete) {
* if (fEntityScanner.scanChar() != '<') {
* reportFatalError("RootElementRequired", null);
* }
* setScannerState(SCANNER_STATE_ROOT_ELEMENT);
* setDriver(fContentDriver);
* }
*/
}
}
// premature end of file
catch (EOFException e) {
//xxx what should be returned here.... ???
return -1 ;
//throw e;
}
//xxx what should be returned here.... ???
return -1;
}
} // class PrologDriver
/**
* Driver to handle the internal and external DTD subsets.
*
* @author Andy Clark, IBM
*/
protected final class DTDDriver
implements Driver {
//
// Driver methods
//
// throw new XNIException("DTD Parsing is currently not supported");
if(DEBUG_NEXT){
}
dispatch(true);
if(DEBUG_NEXT){
}
//xxx: remove this hack and align this with reusing DTD components
//currently this routine will only be executed from Stax
if(fPropertyManager != null){
dtdGrammarUtil = new DTDGrammarUtil(((XMLDTDScannerImpl)fDTDScanner).getGrammar(),fSymbolTable, fNamespaceContext);
}
}
/**
* Dispatch an XML "event".
*
* @param complete True if this driver is intended to scan
* and dispatch as much as possible.
*
* @return True if there is more to dispatch either from this
* or a another driver.
*
* @throws IOException Thrown on i/o error.
* @throws XNIException Thrown on parse error.
*/
throws IOException, XNIException {
try {
boolean again;
if( fDTDScanner == null){
fDTDScanner = new XML11DTDScannerImpl();
} else
fDTDScanner = new XMLDTDScannerImpl();
}
do {
again = false;
switch (fScannerState) {
case SCANNER_STATE_DTD_INTERNAL_DECLS: {
// REVISIT: Should there be a feature for
// the "complete" parameter?
boolean completeDTD = true;
boolean moreToScan = fDTDScanner.scanDTDInternalSubset(completeDTD, fStandalone, fHasExternalDTD && fLoadExternalDTD);
}
fReadingDTD=false;
if (!moreToScan) {
// end doctype declaration
reportFatalError("EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET",
null);
}
}
fMarkupDepth--;
if (!fSupportDTD) {
//simply reset the entity store without having to mess around
//with the DTD Scanner code
} else {
// scan external subset next unless we are ignoring DTDs
break;
}
}
return true;
}
break;
}
case SCANNER_STATE_DTD_EXTERNAL: {
/**
fDTDDescription.setValues(fDoctypePublicId, fDoctypeSystemId, null, null);
fDTDDescription.setRootName(fDoctypeName);
XMLInputSource xmlInputSource =
fEntityManager.resolveEntity(fDTDDescription);
fDTDScanner.setInputSource(xmlInputSource);
setScannerState(SCANNER_STATE_DTD_EXTERNAL_DECLS);
again = true;
break;
*/
// Check access permission. If the source is resolved by a resolver, the check is skipped.
if (!staxInputSource.hasResolver()) {
if (accessError != null) {
reportFatalError("AccessExternalDTD", new Object[]{ SecuritySupport.sanitizePath(fDoctypeSystemId), accessError });
}
}
} else {
}
again = true;
break;
}
case SCANNER_STATE_DTD_EXTERNAL_DECLS: {
// REVISIT: Should there be a feature for
// the "complete" parameter?
boolean completeDTD = true;
if (!moreToScan) {
return true;
}
break;
}
case SCANNER_STATE_PROLOG : {
// skip entity decls
return true;
}
default: {
throw new XNIException("DTDDriver#dispatch: scanner state="+fScannerState+" ("+getScannerStateName(fScannerState)+')');
}
}
}
// premature end of file
catch (EOFException e) {
e.printStackTrace();
return false;
//throw e;
}
// cleanup
finally {
}
return true;
}
// dispatch(boolean):boolean
} // class DTDDriver
/**
* Driver to handle content scanning.
*
* @author Andy Clark, IBM
* @author Eric Ye, IBM
*/
protected class ContentDriver
extends FragmentContentDriver {
//
// Protected methods
//
// hooks
// NOTE: These hook methods are added so that the full document
// scanner can share the majority of code with this class.
/**
* Scan for DOCTYPE hook. This method is a hook for subclasses
* to add code to handle scanning for a the "DOCTYPE" string
* after the string "<!" has been scanned.
*
* @return True if the "DOCTYPE" was scanned; false if "DOCTYPE"
* was not scanned.
*/
protected boolean scanForDoctypeHook()
throws IOException, XNIException {
// fEntityScanner.markStartOfDTD();
return true;
}
return false;
} // scanForDoctypeHook():boolean
/**
* Element depth iz zero. This methos is a hook for subclasses
* to add code to handle when the element depth hits zero. When
* scanning a document fragment, an element depth of zero is
* normal. However, when scanning a full XML document, the
* scanner must handle the trailing miscellanous section of
* the document after the end of the document's root element.
*
* @return True if the caller should stop and return true which
* allows the scanner to switch to a new scanning
* driver. A return value of false indicates that
* the content driver should continue as normal.
*/
protected boolean elementDepthIsZeroHook()
throws IOException, XNIException {
return true;
} // elementDepthIsZeroHook():boolean
/**
* Scan for root element hook. This method is a hook for
* subclasses to add code that handles scanning for the root
* element. When scanning a document fragment, there is no
* "root" element. However, when scanning a full XML document,
* the scanner must handle the root element specially.
*
* @return True if the caller should stop and return true which
* allows the scanner to switch to a new scanning
* driver. A return value of false indicates that
* the content driver should continue as normal.
*/
protected boolean scanRootElementHook()
throws IOException, XNIException {
if (scanStartElement()) {
return true;
}
return false;
} // scanRootElementHook():boolean
/**
* End of file hook. This method is a hook for subclasses to
* add code that handles the end of file. The end of file in
* a document fragment is OK if the markup depth is zero.
* However, when scanning a full XML document, an end of file
* is always premature.
*/
throws IOException, XNIException {
// in case continue-after-fatal-error set, should not do this...
//throw e;
} // endOfFileHook()
protected void resolveExternalSubsetAndRead()
throws IOException, XNIException {
fDTDDescription.setValues(null, null, fEntityManager.getCurrentResourceIdentifier().getExpandedSystemId(), null);
// call document handler
if (fDocumentHandler != null) {
// This inserts a doctypeDecl event into the stream though no
// DOCTYPE existed in the instance document.
}
try {
while (fDTDScanner.scanDTDExternalSubset(true));
} finally {
}
}
} // resolveExternalSubsetAndRead()
} // class ContentDriver
/**
* Driver to handle trailing miscellaneous section scanning.
*
* @author Andy Clark, IBM
* @author Eric Ye, IBM
*/
protected final class TrailingMiscDriver
implements Driver {
//
// Driver methods
//
//this could for cases like <foo/>
//look at scanRootElementHook
if(fEmptyElement){
fEmptyElement = false;
return XMLEvent.END_ELEMENT;
}
try {
return XMLEvent.END_DOCUMENT ;}
do {
switch (fScannerState) {
case SCANNER_STATE_TRAILING_MISC: {
//we should have reached the end of the document in
//most cases.
if(fScannerState == SCANNER_STATE_TERMINATED ){
return XMLEvent.END_DOCUMENT ;
}
} else {
}
break;
}
case SCANNER_STATE_START_OF_MARKUP: {
fMarkupDepth++;
reportFatalError("MarkupNotRecognizedInMisc",
null);
reportFatalError("MarkupNotRecognizedInMisc",
null);
} else {
reportFatalError("MarkupNotRecognizedInMisc",
null);
}
break;
}
}
}while(fScannerState == SCANNER_STATE_START_OF_MARKUP || fScannerState == SCANNER_STATE_TRAILING_MISC);
if(DEBUG_NEXT){
System.out.println("State set by deciding while loop [TrailingMiscellaneous] is = " + getScannerStateName(fScannerState));
}
switch (fScannerState){
case SCANNER_STATE_PI: {
return XMLEvent.PROCESSING_INSTRUCTION ;
}
case SCANNER_STATE_COMMENT: {
}
scanComment();
}
case SCANNER_STATE_CONTENT: {
if (ch == -1) {
return XMLEvent.END_DOCUMENT ;
} else{
reportFatalError("ContentIllegalInTrailingMisc",
null);
return XMLEvent.CHARACTERS;
}
}
case SCANNER_STATE_REFERENCE: {
reportFatalError("ReferenceIllegalInTrailingMisc",
null);
return XMLEvent.ENTITY_REFERENCE ;
}
case SCANNER_STATE_TERMINATED: {
//there can't be any element after SCANNER_STATE_TERMINATED or when the parser
//has reached the end of document
//xxx what to do when the scanner has reached the terminating state.
return XMLEvent.END_DOCUMENT ;
}
}
}//switch
} catch (EOFException e) {
// NOTE: This is the only place we're allowed to reach
// the real end of the document stream. Unless the
// end of file was reached prematurely.
if (fMarkupDepth != 0) {
return -1;
//throw e;
}
//System.out.println("EOFException thrown") ;
}
return XMLEvent.END_DOCUMENT;
}//next
} // class TrailingMiscDriver
/**
* Implements XMLBufferListener interface.
*/
/**
* receives callbacks from {@link XMLEntityReader } when buffer
* is being changed.
* @param refreshPosition
*/
super.refresh(refreshPosition);
if(fReadingDTD){
}
}
}
} // class XMLDocumentScannerImpl