com.sun.xml.stream
Class XMLDocumentFragmentScannerImpl

java.lang.Object
  extended by com.sun.xml.stream.XMLScanner
      extended by com.sun.xml.stream.XMLDocumentFragmentScannerImpl
All Implemented Interfaces:
XMLEntityHandler, org.apache.xerces.xni.parser.XMLComponent, org.apache.xerces.xni.parser.XMLDocumentScanner, org.apache.xerces.xni.parser.XMLDocumentSource
Direct Known Subclasses:
XMLDocumentScannerImpl

public class XMLDocumentFragmentScannerImpl
extends XMLScanner
implements org.apache.xerces.xni.parser.XMLDocumentScanner, org.apache.xerces.xni.parser.XMLComponent, XMLEntityHandler

This class is responsible for scanning the structure and content of document fragments. 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.

Version:
$Id: XMLDocumentFragmentScannerImpl.java,v 1.9 2007-12-06 17:24:01 joehw Exp $
Author:
Neeraj Bajaj SUN Microsystems, K.Venugopal SUN Microsystems, Glenn Marcy, IBM, Andy Clark, IBM, Arnaud Le Hors, IBM, Eric Ye, IBM, Sunitha Reddy SUN Microsystems

Nested Class Summary
protected static interface XMLDocumentFragmentScannerImpl.Driver
          Drives the parser to the next state/event on the input.
protected static class XMLDocumentFragmentScannerImpl.Element
           
protected  class XMLDocumentFragmentScannerImpl.ElementStack
          Element stack.
protected  class XMLDocumentFragmentScannerImpl.ElementStack2
          Element stack.
protected  class XMLDocumentFragmentScannerImpl.FragmentContentDriver
          Driver to handle content scanning.
 
Field Summary
protected static char[] cdata
           
protected static boolean DEBUG
          Debug driver next
protected static boolean DEBUG_COALESCE
           
protected static boolean DEBUG_CONTENT_SCANNING
          Debug content driver scanning.
protected static boolean DEBUG_NEXT
          Debug driver next
protected  DTDGrammarUtil dtdGrammarUtil
           
protected static char[] endTag
           
protected  boolean fAdd
           
protected  boolean fAddDefaultAttr
           
protected  org.apache.xerces.xni.QName fAttributeQName
          Attribute QName.
protected  org.apache.xerces.util.XMLAttributesIteratorImpl fAttributes
          CHANGED: Using XMLAttributesIteratorImpl instead of XMLAttributesImpl.
protected  org.apache.xerces.util.XMLStringBuffer fContentBuffer
          Making the buffer accesible to derived class -- stores PI data
protected  XMLDocumentFragmentScannerImpl.Driver fContentDriver
          Content driver.
protected  org.apache.xerces.xni.QName fCurrentElement
          Current element.
protected  java.lang.String fDeclaredEncoding
           
protected  boolean fDisallowDoctype
          Disallow doctype declaration.
protected  org.apache.xerces.xni.XMLDocumentHandler fDocumentHandler
          Document handler.
protected  XMLDocumentFragmentScannerImpl.Driver fDriver
          Active driver.
protected  org.apache.xerces.xni.QName fElementQName
          Element QName.
protected  java.lang.String fElementRawname
           
protected  XMLDocumentFragmentScannerImpl.ElementStack fElementStack
          Element stack.
protected  XMLDocumentFragmentScannerImpl.ElementStack2 fElementStack2
           
protected  boolean fEmptyElement
           
protected  int[] fEntityStack
          Entity stack.
protected  XMLEntityStorage fEntityStore
          Entity Storage
protected  boolean fHasExternalDTD
          has external dtd
protected  boolean fInScanContent
          SubScanner state: inside scanContent method.
protected  boolean fIsCoalesce
           
protected  boolean fLastSectionWasCData
           
protected  boolean fLastSectionWasCharacterData
           
protected  boolean fLastSectionWasEntityReference
           
protected  int fMarkupDepth
          Markup depth.
protected  boolean fNamespaces
          Namespaces.
protected  boolean fNotifyBuiltInRefs
          Notify built-in references.
protected  boolean foundBuiltInRefs
           
protected  org.apache.xerces.xni.XMLString fPIData
           
protected  java.lang.String fPITarget
          Document system identifier.
protected  boolean fReplaceEntityReferences
           
protected  boolean fReportCdataEvent
           
protected  int fScannerState
          Scanner state.
protected  boolean fScanToEnd
           
protected  boolean fShouldSkip
           
protected  boolean fSkip
           
protected  boolean fStandalone
           
protected  boolean fStandaloneSet
          Standalone.
protected  org.apache.xerces.util.XMLStringBuffer fStringBuffer
          Making the buffer accesible to derived class -- String buffer.
protected  org.apache.xerces.util.XMLStringBuffer fStringBuffer2
          Making the buffer accesible to derived class -- String buffer.
protected  boolean fSupportExternalEntities
           
protected  org.apache.xerces.xni.XMLString fTempString
          String.
protected  org.apache.xerces.xni.XMLString fTempString2
          String.
protected  java.lang.String fVersion
           
protected static java.lang.String NAMESPACES
          Feature identifier: namespaces.
protected static java.lang.String NOTIFY_BUILTIN_REFS
          Feature identifier: notify built-in refereces.
protected static int SCANNER_STATE_ATTRIBUTE
           
protected static int SCANNER_STATE_ATTRIBUTE_VALUE
           
protected static int SCANNER_STATE_BUILT_IN_REFS
           
protected static int SCANNER_STATE_CDATA
          Scanner state: CDATA section.
protected static int SCANNER_STATE_CHAR_REFERENCE
           
protected static int SCANNER_STATE_CHARACTER_DATA
          Scanner state: Text declaration.
protected static int SCANNER_STATE_COMMENT
          Scanner state: comment.
protected static int SCANNER_STATE_CONTENT
          Scanner state: content.
protected static int SCANNER_STATE_DOCTYPE
          Scanner state: DOCTYPE.
protected static int SCANNER_STATE_END_ELEMENT_TAG
           
protected static int SCANNER_STATE_END_OF_INPUT
          Scanner state: end of input.
protected static int SCANNER_STATE_PI
          Scanner state: processing instruction.
protected static int SCANNER_STATE_REFERENCE
          Scanner state: reference.
protected static int SCANNER_STATE_ROOT_ELEMENT
          Scanner state: root element.
protected static int SCANNER_STATE_START_ELEMENT_TAG
           
protected static int SCANNER_STATE_START_OF_MARKUP
          Scanner state: start of markup.
protected static int SCANNER_STATE_TERMINATED
          Scanner state: terminated.
protected static int SCANNER_STATE_TEXT_DECL
          Scanner state: Text declaration.
protected static int SCANNER_STATE_XML_DECL
          Scanner state: XML Declaration
protected static char[] xmlDecl
           
 
Fields inherited from class com.sun.xml.stream.XMLScanner
attributeValueCache, DEBUG_ATTR_NORMALIZATION, ENTITY_MANAGER, ERROR_REPORTER, fAmpSymbol, fAposSymbol, fAttributeCacheInitDone, fAttributeCacheUsedCount, fCharRefLiteral, fEncodingSymbol, fEntityDepth, fEntityManager, fEntityScanner, fErrorReporter, fEvent, fGtSymbol, fLtSymbol, fNotifyCharRefs, fPropertyManager, fQuotSymbol, fReportEntity, fResourceIdentifier, fScanningAttribute, fStandaloneSymbol, fStringBufferIndex, fSymbolTable, fValidation, fVersionSymbol, NOTIFY_CHAR_REFS, stringBufferCache, SYMBOL_TABLE, VALIDATION
 
Constructor Summary
XMLDocumentFragmentScannerImpl()
          Default constructor.
 
Method Summary
protected  XMLDocumentFragmentScannerImpl.Driver createContentDriver()
          Creates a content Driver.
 void endEntity(java.lang.String name)
          This method notifies the end of an entity.
 org.apache.xerces.util.XMLAttributesIteratorImpl getAttributeIterator()
          return the attribute iterator implementation
 org.apache.xerces.xni.XMLString getCharacterData()
           
 java.lang.String getComment()
           
 org.apache.xerces.xni.XMLDocumentHandler getDocumentHandler()
          Returns the document handler
 java.lang.String getDriverName(XMLDocumentFragmentScannerImpl.Driver driver)
          Returns the driver name.
 java.lang.String getEntityName()
           
 java.lang.Boolean getFeatureDefault(java.lang.String featureId)
          Returns the default state for a feature, or null if this component does not want to report a default value for this feature.
 org.apache.xerces.util.XMLStringBuffer getPIData()
           
 java.lang.String getPITarget()
           
 java.lang.Object getPropertyDefault(java.lang.String propertyId)
          Returns the default state for a property, or null if this component does not want to report a default value for this property.
 java.lang.String[] getRecognizedFeatures()
          Returns a list of feature identifiers that are recognized by this component.
 java.lang.String[] getRecognizedProperties()
          Returns a list of property identifiers that are recognized by this component.
protected  java.lang.String getScannerStateName(int state)
          Returns the scanner state name.
 boolean hasAttributes()
           
 boolean isStandAlone()
          return if the doucment is standalone
 int next()
          return the next state on the input
 void reset(PropertyManager propertyManager)
           
 void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
          Resets the component.
protected  void scanAttribute(org.apache.xerces.xni.XMLAttributes attributes)
          Scans an attribute name value pair.
protected  boolean scanCDATASection(org.apache.xerces.util.XMLStringBuffer contentBuffer, boolean complete)
          Scans a CDATA section.
protected  void scanCharReference()
          Scans a character reference.
protected  void scanComment()
          Scans a comment.
protected  int scanContent(org.apache.xerces.util.XMLStringBuffer content)
          Scans element content.
 boolean scanDocument(boolean complete)
          Scans a document.
protected  int scanEndElement()
          Scans an end element.
protected  void scanEntityReference(org.apache.xerces.util.XMLStringBuffer content)
          Scans an entity reference.
protected  void scanPIData(java.lang.String target, org.apache.xerces.util.XMLStringBuffer data)
          Scans a processing data.
protected  boolean scanStartElement()
          Scans a start element.
protected  void scanXMLDeclOrTextDecl(boolean scanningTextDecl)
          Scans an XML or text declaration.
 void setDocumentHandler(org.apache.xerces.xni.XMLDocumentHandler documentHandler)
          setDocumentHandler
protected  void setDriver(XMLDocumentFragmentScannerImpl.Driver driver)
          Sets the Driver.
 void setFeature(java.lang.String featureId, boolean state)
          Sets the state of a feature.
 void setInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)
          Sets the input source.
 void setProperty(java.lang.String propertyId, java.lang.Object value)
          Sets the value of a property.
protected  void setScannerState(int state)
          Sets the scanner state.
protected  boolean skipElement()
           
 boolean standaloneSet()
          return if standalone is set
 void startEntity(java.lang.String name, org.apache.xerces.xni.XMLResourceIdentifier identifier, java.lang.String encoding)
          This method notifies of the start of an entity.
 
Methods inherited from class com.sun.xml.stream.XMLScanner
getFeature, isInvalid, isInvalidLiteral, isValidNameChar, isValidNameStartChar, isValidNCName, normalizeWhitespace, reportFatalError, scanAttributeValue, scanCharReferenceValue, scanComment, scanExternalID, scanPI, scanPseudoAttribute, scanPubidLiteral, scanSurrogates, scanXMLDeclOrTextDecl, setPropertyManager, versionSupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCANNER_STATE_START_OF_MARKUP

protected static final int SCANNER_STATE_START_OF_MARKUP
Scanner state: start of markup.

See Also:
Constant Field Values

SCANNER_STATE_CONTENT

protected static final int SCANNER_STATE_CONTENT
Scanner state: content.

See Also:
Constant Field Values

SCANNER_STATE_PI

protected static final int SCANNER_STATE_PI
Scanner state: processing instruction.

See Also:
Constant Field Values

SCANNER_STATE_DOCTYPE

protected static final int SCANNER_STATE_DOCTYPE
Scanner state: DOCTYPE.

See Also:
Constant Field Values

SCANNER_STATE_XML_DECL

protected static final int SCANNER_STATE_XML_DECL
Scanner state: XML Declaration

See Also:
Constant Field Values

SCANNER_STATE_ROOT_ELEMENT

protected static final int SCANNER_STATE_ROOT_ELEMENT
Scanner state: root element.

See Also:
Constant Field Values

SCANNER_STATE_COMMENT

protected static final int SCANNER_STATE_COMMENT
Scanner state: comment.

See Also:
Constant Field Values

SCANNER_STATE_REFERENCE

protected static final int SCANNER_STATE_REFERENCE
Scanner state: reference.

See Also:
Constant Field Values

SCANNER_STATE_ATTRIBUTE

protected static final int SCANNER_STATE_ATTRIBUTE
See Also:
Constant Field Values

SCANNER_STATE_ATTRIBUTE_VALUE

protected static final int SCANNER_STATE_ATTRIBUTE_VALUE
See Also:
Constant Field Values

SCANNER_STATE_END_OF_INPUT

protected static final int SCANNER_STATE_END_OF_INPUT
Scanner state: end of input.

See Also:
Constant Field Values

SCANNER_STATE_TERMINATED

protected static final int SCANNER_STATE_TERMINATED
Scanner state: terminated.

See Also:
Constant Field Values

SCANNER_STATE_CDATA

protected static final int SCANNER_STATE_CDATA
Scanner state: CDATA section.

See Also:
Constant Field Values

SCANNER_STATE_TEXT_DECL

protected static final int SCANNER_STATE_TEXT_DECL
Scanner state: Text declaration.

See Also:
Constant Field Values

SCANNER_STATE_CHARACTER_DATA

protected static final int SCANNER_STATE_CHARACTER_DATA
Scanner state: Text declaration.

See Also:
Constant Field Values

SCANNER_STATE_START_ELEMENT_TAG

protected static final int SCANNER_STATE_START_ELEMENT_TAG
See Also:
Constant Field Values

SCANNER_STATE_END_ELEMENT_TAG

protected static final int SCANNER_STATE_END_ELEMENT_TAG
See Also:
Constant Field Values

SCANNER_STATE_CHAR_REFERENCE

protected static final int SCANNER_STATE_CHAR_REFERENCE
See Also:
Constant Field Values

SCANNER_STATE_BUILT_IN_REFS

protected static final int SCANNER_STATE_BUILT_IN_REFS
See Also:
Constant Field Values

NAMESPACES

protected static final java.lang.String NAMESPACES
Feature identifier: namespaces.

See Also:
Constant Field Values

NOTIFY_BUILTIN_REFS

protected static final java.lang.String NOTIFY_BUILTIN_REFS
Feature identifier: notify built-in refereces.

See Also:
Constant Field Values

cdata

protected static final char[] cdata

xmlDecl

protected static final char[] xmlDecl

endTag

protected static final char[] endTag

DEBUG_CONTENT_SCANNING

protected static final boolean DEBUG_CONTENT_SCANNING
Debug content driver scanning.

See Also:
Constant Field Values

DEBUG_NEXT

protected static final boolean DEBUG_NEXT
Debug driver next

See Also:
Constant Field Values

DEBUG

protected static final boolean DEBUG
Debug driver next

See Also:
Constant Field Values

DEBUG_COALESCE

protected static final boolean DEBUG_COALESCE
See Also:
Constant Field Values

fDocumentHandler

protected org.apache.xerces.xni.XMLDocumentHandler fDocumentHandler
Document handler.


fEntityStore

protected XMLEntityStorage fEntityStore
Entity Storage


fEntityStack

protected int[] fEntityStack
Entity stack.


fMarkupDepth

protected int fMarkupDepth
Markup depth.


fEmptyElement

protected boolean fEmptyElement

fScannerState

protected int fScannerState
Scanner state.


fInScanContent

protected boolean fInScanContent
SubScanner state: inside scanContent method.


fLastSectionWasCData

protected boolean fLastSectionWasCData

fLastSectionWasEntityReference

protected boolean fLastSectionWasEntityReference

fLastSectionWasCharacterData

protected boolean fLastSectionWasCharacterData

fHasExternalDTD

protected boolean fHasExternalDTD
has external dtd


fStandaloneSet

protected boolean fStandaloneSet
Standalone.


fStandalone

protected boolean fStandalone

fVersion

protected java.lang.String fVersion

fCurrentElement

protected org.apache.xerces.xni.QName fCurrentElement
Current element.


fElementStack

protected XMLDocumentFragmentScannerImpl.ElementStack fElementStack
Element stack.


fElementStack2

protected XMLDocumentFragmentScannerImpl.ElementStack2 fElementStack2

fPITarget

protected java.lang.String fPITarget
Document system identifier. REVISIT: So what's this used for? - NG protected String fDocumentSystemId;


fPIData

protected org.apache.xerces.xni.XMLString fPIData

fNamespaces

protected boolean fNamespaces
Namespaces.


fNotifyBuiltInRefs

protected boolean fNotifyBuiltInRefs
Notify built-in references.


fReplaceEntityReferences

protected boolean fReplaceEntityReferences

fSupportExternalEntities

protected boolean fSupportExternalEntities

fReportCdataEvent

protected boolean fReportCdataEvent

fIsCoalesce

protected boolean fIsCoalesce

fDeclaredEncoding

protected java.lang.String fDeclaredEncoding

fDisallowDoctype

protected boolean fDisallowDoctype
Disallow doctype declaration.


fDriver

protected XMLDocumentFragmentScannerImpl.Driver fDriver
Active driver.


fContentDriver

protected XMLDocumentFragmentScannerImpl.Driver fContentDriver
Content driver.


fElementQName

protected org.apache.xerces.xni.QName fElementQName
Element QName.


fAttributeQName

protected org.apache.xerces.xni.QName fAttributeQName
Attribute QName.


fAttributes

protected org.apache.xerces.util.XMLAttributesIteratorImpl fAttributes
CHANGED: Using XMLAttributesIteratorImpl instead of XMLAttributesImpl. This class implements Iterator interface so we can directly give Attributes in the form of iterator.


fTempString

protected org.apache.xerces.xni.XMLString fTempString
String.


fTempString2

protected org.apache.xerces.xni.XMLString fTempString2
String.


fStringBuffer

protected org.apache.xerces.util.XMLStringBuffer fStringBuffer
Making the buffer accesible to derived class -- String buffer.


fStringBuffer2

protected org.apache.xerces.util.XMLStringBuffer fStringBuffer2
Making the buffer accesible to derived class -- String buffer.


fContentBuffer

protected org.apache.xerces.util.XMLStringBuffer fContentBuffer
Making the buffer accesible to derived class -- stores PI data


fScanToEnd

protected boolean fScanToEnd

dtdGrammarUtil

protected DTDGrammarUtil dtdGrammarUtil

fAddDefaultAttr

protected boolean fAddDefaultAttr

foundBuiltInRefs

protected boolean foundBuiltInRefs

fElementRawname

protected java.lang.String fElementRawname

fShouldSkip

protected boolean fShouldSkip

fAdd

protected boolean fAdd

fSkip

protected boolean fSkip
Constructor Detail

XMLDocumentFragmentScannerImpl

public XMLDocumentFragmentScannerImpl()
Default constructor.

Method Detail

setInputSource

public void setInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)
                    throws java.io.IOException
Sets the input source.

Specified by:
setInputSource in interface org.apache.xerces.xni.parser.XMLDocumentScanner
Parameters:
inputSource - The input source.
Throws:
java.io.IOException - Thrown on i/o error.

scanDocument

public boolean scanDocument(boolean complete)
                     throws java.io.IOException,
                            org.apache.xerces.xni.XNIException
Scans a document.

Specified by:
scanDocument in interface org.apache.xerces.xni.parser.XMLDocumentScanner
Parameters:
complete - True if the scanner should scan the document completely, pushing all events to the registered document handler. A value of false indicates that that the scanner should only scan the next portion of the document and return. A scanner instance is permitted to completely scan a document if it does not support this "pull" scanning model.
Returns:
True if there is more to scan, false otherwise.
Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

next

public int next()
         throws java.io.IOException,
                org.apache.xerces.xni.XNIException
return the next state on the input

Specified by:
next in interface org.apache.xerces.xni.parser.XMLDocumentScanner
Returns:
int
Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

reset

public void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
           throws org.apache.xerces.xni.parser.XMLConfigurationException
Resets the component. The component can query the component manager about any features and properties that affect the operation of the component.

Specified by:
reset in interface org.apache.xerces.xni.parser.XMLComponent
Overrides:
reset in class XMLScanner
Parameters:
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.
org.apache.xerces.xni.parser.XMLConfigurationException

reset

public void reset(PropertyManager propertyManager)
Overrides:
reset in class XMLScanner

getRecognizedFeatures

public java.lang.String[] getRecognizedFeatures()
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.

Specified by:
getRecognizedFeatures in interface org.apache.xerces.xni.parser.XMLComponent

setFeature

public void setFeature(java.lang.String featureId,
                       boolean state)
                throws org.apache.xerces.xni.parser.XMLConfigurationException
Sets the state of a feature. This method is called by the component manager any time after reset when a feature changes state.

Note: Components should silently ignore features that do not affect the operation of the component.

Specified by:
setFeature in interface org.apache.xerces.xni.parser.XMLComponent
Overrides:
setFeature in class XMLScanner
Parameters:
featureId - The feature identifier.
state - The state of the feature.
Throws:
SAXNotRecognizedException - The component should not throw this exception.
SAXNotSupportedException - The component should not throw this exception.
org.apache.xerces.xni.parser.XMLConfigurationException - Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.

getRecognizedProperties

public java.lang.String[] getRecognizedProperties()
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.

Specified by:
getRecognizedProperties in interface org.apache.xerces.xni.parser.XMLComponent

setProperty

public void setProperty(java.lang.String propertyId,
                        java.lang.Object value)
                 throws org.apache.xerces.xni.parser.XMLConfigurationException
Sets the value of a property. This method is called by the component manager any time after reset when a property changes value.

Note: Components should silently ignore properties that do not affect the operation of the component.

Specified by:
setProperty in interface org.apache.xerces.xni.parser.XMLComponent
Overrides:
setProperty in class XMLScanner
Parameters:
propertyId - The property identifier.
value - The value of the property.
Throws:
SAXNotRecognizedException - The component should not throw this exception.
SAXNotSupportedException - The component should not throw this exception.
org.apache.xerces.xni.parser.XMLConfigurationException - Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.

getFeatureDefault

public java.lang.Boolean getFeatureDefault(java.lang.String featureId)
Returns the default state for a feature, or null if this component does not want to report a default value for this feature.

Specified by:
getFeatureDefault in interface org.apache.xerces.xni.parser.XMLComponent
Parameters:
featureId - The feature identifier.
Since:
Xerces 2.2.0

getPropertyDefault

public java.lang.Object getPropertyDefault(java.lang.String propertyId)
Returns the default state for a property, or null if this component does not want to report a default value for this property.

Specified by:
getPropertyDefault in interface org.apache.xerces.xni.parser.XMLComponent
Parameters:
propertyId - The property identifier.
Since:
Xerces 2.2.0

setDocumentHandler

public void setDocumentHandler(org.apache.xerces.xni.XMLDocumentHandler documentHandler)
setDocumentHandler

Specified by:
setDocumentHandler in interface org.apache.xerces.xni.parser.XMLDocumentSource
Parameters:
documentHandler -

getDocumentHandler

public org.apache.xerces.xni.XMLDocumentHandler getDocumentHandler()
Returns the document handler

Specified by:
getDocumentHandler in interface org.apache.xerces.xni.parser.XMLDocumentSource

startEntity

public void startEntity(java.lang.String name,
                        org.apache.xerces.xni.XMLResourceIdentifier identifier,
                        java.lang.String encoding)
                 throws org.apache.xerces.xni.XNIException
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.

Specified by:
startEntity in interface XMLEntityHandler
Overrides:
startEntity in class XMLScanner
Parameters:
name - The name of the entity.
identifier - The resource identifier.
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:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

endEntity

public void endEntity(java.lang.String name)
               throws java.io.IOException,
                      org.apache.xerces.xni.XNIException
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.

Specified by:
endEntity in interface XMLEntityHandler
Overrides:
endEntity in class XMLScanner
Parameters:
name - The name of the entity.
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.
java.io.IOException

createContentDriver

protected XMLDocumentFragmentScannerImpl.Driver createContentDriver()
Creates a content Driver.


scanXMLDeclOrTextDecl

protected void scanXMLDeclOrTextDecl(boolean scanningTextDecl)
                              throws java.io.IOException,
                                     org.apache.xerces.xni.XNIException
Scans an XML or text declaration.

 [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
 [24] VersionInfo ::= S 'version' Eq (' VersionNum ' | " VersionNum ")
 [80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' |  "'" EncName "'" )
 [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
 [32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'")
                 | ('"' ('yes' | 'no') '"'))

 [77] TextDecl ::= '<?xml' VersionInfo? EncodingDecl S? '?>'
 

Parameters:
scanningTextDecl - True if a text declaration is to be scanned instead of an XML declaration.
Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

getPITarget

public java.lang.String getPITarget()

getPIData

public org.apache.xerces.util.XMLStringBuffer getPIData()

getCharacterData

public org.apache.xerces.xni.XMLString getCharacterData()

scanPIData

protected void scanPIData(java.lang.String target,
                          org.apache.xerces.util.XMLStringBuffer data)
                   throws java.io.IOException,
                          org.apache.xerces.xni.XNIException
Scans a processing data. This is needed to handle the situation where a document starts with a processing instruction whose target name starts with "xml". (e.g. xmlfoo)

Overrides:
scanPIData in class XMLScanner
Parameters:
target - The PI target
data - The XMLStringBuffer to fill in with the data
Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

scanComment

protected void scanComment()
                    throws java.io.IOException,
                           org.apache.xerces.xni.XNIException
Scans a comment.

 [15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
 

Note: Called after scanning past '<!--'

Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

getComment

public java.lang.String getComment()

skipElement

protected boolean skipElement()
                       throws java.io.IOException
Throws:
java.io.IOException

scanStartElement

protected boolean scanStartElement()
                            throws java.io.IOException,
                                   org.apache.xerces.xni.XNIException
Scans a start element. This method will handle the binding of namespace information and notifying the handler of the start of the element.

 [44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
 [40] STag ::= '<' Name (S Attribute)* S? '>'
 

Note: This method assumes that the leading '<' character has been consumed.

Note: This method uses the fElementQName and fAttributes variables. The contents of these variables will be destroyed. The caller should copy important information out of these variables before calling this method. NB: Content in fAttributes is valid only till the state of the parser is XMLEvent.START_ELEMENT

Returns:
True if element is empty. (i.e. It matches production [44].
Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

hasAttributes

public boolean hasAttributes()

getAttributeIterator

public org.apache.xerces.util.XMLAttributesIteratorImpl getAttributeIterator()
return the attribute iterator implementation


standaloneSet

public boolean standaloneSet()
return if standalone is set


isStandAlone

public boolean isStandAlone()
return if the doucment is standalone


scanAttribute

protected void scanAttribute(org.apache.xerces.xni.XMLAttributes attributes)
                      throws java.io.IOException,
                             org.apache.xerces.xni.XNIException
Scans an attribute name value pair.

 [41] Attribute ::= Name Eq AttValue
 

Note: This method assumes that the next character on the stream is the first character of the attribute name.

Note: This method uses the fAttributeQName and fQName variables. The contents of these variables will be destroyed.

Parameters:
attributes - The attributes list for the scanned attribute.
Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

scanContent

protected int scanContent(org.apache.xerces.util.XMLStringBuffer content)
                   throws java.io.IOException,
                          org.apache.xerces.xni.XNIException
Scans element content.

Returns:
Returns the next character on the stream.
Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

scanCDATASection

protected boolean scanCDATASection(org.apache.xerces.util.XMLStringBuffer contentBuffer,
                                   boolean complete)
                            throws java.io.IOException,
                                   org.apache.xerces.xni.XNIException
Scans a CDATA section.

Note: This method uses the fTempString and fStringBuffer variables.

Parameters:
complete - True if the CDATA section is to be scanned completely.
Returns:
True if CDATA is completely scanned.
Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

scanEndElement

protected int scanEndElement()
                      throws java.io.IOException,
                             org.apache.xerces.xni.XNIException
Scans an end element.

 [42] ETag ::= '</' Name S? '>'
 

Note: This method uses the fElementQName variable. The contents of this variable will be destroyed. The caller should copy the needed information out of this variable before calling this method.

Returns:
The element depth.
Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

scanCharReference

protected void scanCharReference()
                          throws java.io.IOException,
                                 org.apache.xerces.xni.XNIException
Scans a character reference.

 [66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'
 

Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

scanEntityReference

protected void scanEntityReference(org.apache.xerces.util.XMLStringBuffer content)
                            throws java.io.IOException,
                                   org.apache.xerces.xni.XNIException
Scans an entity reference.

Throws:
java.io.IOException - Thrown if i/o error occurs.
org.apache.xerces.xni.XNIException - Thrown if handler throws exception upon notification.

setScannerState

protected final void setScannerState(int state)
Sets the scanner state.

Parameters:
state - The new scanner state.

setDriver

protected final void setDriver(XMLDocumentFragmentScannerImpl.Driver driver)
Sets the Driver.

Parameters:
Driver - The new Driver.

getScannerStateName

protected java.lang.String getScannerStateName(int state)
Returns the scanner state name.


getEntityName

public java.lang.String getEntityName()

getDriverName

public java.lang.String getDriverName(XMLDocumentFragmentScannerImpl.Driver driver)
Returns the driver name.



Copyright ? 2002-2003 Apache XML Project. All Rights Reserved.