Class XMLDocumentScannerImpl
- java.lang.Object
-
- org.smooks.engine.delivery.sax.ng.org.apache.xerces.impl.XMLScanner
-
- org.smooks.engine.delivery.sax.ng.org.apache.xerces.impl.XMLDocumentFragmentScannerImpl
-
- org.smooks.engine.delivery.sax.ng.org.apache.xerces.impl.XMLDocumentScannerImpl
-
- All Implemented Interfaces:
XMLEntityHandler
,XMLComponent
,XMLDocumentScanner
,XMLDocumentSource
- Direct Known Subclasses:
XML11DocumentScannerImpl
,XMLNSDocumentScannerImpl
public class XMLDocumentScannerImpl extends XMLDocumentFragmentScannerImpl
This class is responsible for scanning XML document structure and content. The scanner acts as the source for the document information which is communicated to the document handler.This component requires the following features and properties from the component manager that uses it:
- http://xml.org/sax/features/namespaces
- http://xml.org/sax/features/validation
- http://apache.org/xml/features/nonvalidating/load-external-dtd
- http://apache.org/xml/features/scanner/notify-char-refs
- http://apache.org/xml/features/scanner/notify-builtin-refs
- http://apache.org/xml/properties/internal/symbol-table
- http://apache.org/xml/properties/internal/error-reporter
- http://apache.org/xml/properties/internal/entity-manager
- http://apache.org/xml/properties/internal/dtd-scanner
- Version:
- $Id$
- Author:
- Glenn Marcy, IBM, Andy Clark, IBM, Arnaud Le Hors, IBM, Eric Ye, IBM
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
XMLDocumentScannerImpl.ContentDispatcher
Dispatcher to handle content scanning.protected class
XMLDocumentScannerImpl.DTDDispatcher
Dispatcher to handle the internal and external DTD subsets.protected class
XMLDocumentScannerImpl.PrologDispatcher
Dispatcher to handle prolog scanning.protected class
XMLDocumentScannerImpl.TrailingMiscDispatcher
Dispatcher to handle trailing miscellaneous section scanning.protected class
XMLDocumentScannerImpl.XMLDeclDispatcher
Dispatcher to handle XMLDecl scanning.-
Nested classes/interfaces inherited from class org.smooks.engine.delivery.sax.ng.org.apache.xerces.impl.XMLDocumentFragmentScannerImpl
XMLDocumentFragmentScannerImpl.Dispatcher, XMLDocumentFragmentScannerImpl.ElementStack, XMLDocumentFragmentScannerImpl.FragmentContentDispatcher
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
DISALLOW_DOCTYPE_DECL_FEATURE
Feature identifier: load external DTD.protected static String
DTD_SCANNER
Property identifier: DTD scanner.protected boolean
fDisallowDoctype
Disallow doctype declaration.protected String
fDoctypeName
Doctype name.protected String
fDoctypePublicId
Doctype declaration public identifier.protected String
fDoctypeSystemId
Doctype declaration system identifier.protected XMLDocumentFragmentScannerImpl.Dispatcher
fDTDDispatcher
DTD dispatcher.protected XMLDTDScanner
fDTDScanner
DTD scanner.protected boolean
fLoadExternalDTD
Load external DTD.protected NamespaceContext
fNamespaceContext
Namespace support.protected XMLDocumentFragmentScannerImpl.Dispatcher
fPrologDispatcher
Prolog dispatcher.protected boolean
fScanningDTD
Scanning DTD.protected boolean
fSeenDoctypeDecl
Seen doctype declaration.protected XMLDocumentFragmentScannerImpl.Dispatcher
fTrailingMiscDispatcher
Trailing miscellaneous section dispatcher.protected ValidationManager
fValidationManager
Validation manager .protected XMLDocumentFragmentScannerImpl.Dispatcher
fXMLDeclDispatcher
XML declaration dispatcher.protected static String
LOAD_EXTERNAL_DTD
Feature identifier: load external DTD.protected static String
NAMESPACE_CONTEXT
property identifier: NamespaceContextprotected static int
SCANNER_STATE_DTD_EXTERNAL
Scanner state: open DTD external subset.protected static int
SCANNER_STATE_DTD_EXTERNAL_DECLS
Scanner state: DTD external declarations.protected static int
SCANNER_STATE_DTD_INTERNAL_DECLS
Scanner state: DTD internal declarations.protected static int
SCANNER_STATE_PROLOG
Scanner state: prolog.protected static int
SCANNER_STATE_TRAILING_MISC
Scanner state: trailing misc.protected static int
SCANNER_STATE_XML_DECL
Scanner state: XML declaration.protected static String
VALIDATION_MANAGER
property identifier: ValidationManager-
Fields inherited from class org.smooks.engine.delivery.sax.ng.org.apache.xerces.impl.XMLDocumentFragmentScannerImpl
DEBUG_CONTENT_SCANNING, ENTITY_RESOLVER, fAttributeQName, fAttributes, fContentDispatcher, fCurrentElement, fDispatcher, fDocumentHandler, fElementQName, fElementStack, fEntityStack, fExternalSubsetResolver, fHasExternalDTD, fInScanContent, fIsEntityDeclaredVC, fMarkupDepth, fNotifyBuiltInRefs, fScannerState, fStandalone, fTempString, fTempString2, NAMESPACES, NOTIFY_BUILTIN_REFS, SCANNER_STATE_CDATA, SCANNER_STATE_COMMENT, SCANNER_STATE_CONTENT, SCANNER_STATE_DOCTYPE, SCANNER_STATE_END_OF_INPUT, SCANNER_STATE_PI, SCANNER_STATE_REFERENCE, SCANNER_STATE_ROOT_ELEMENT, SCANNER_STATE_START_OF_MARKUP, SCANNER_STATE_TERMINATED, SCANNER_STATE_TEXT_DECL
-
Fields inherited from class org.smooks.engine.delivery.sax.ng.org.apache.xerces.impl.XMLScanner
DEBUG_ATTR_NORMALIZATION, ENTITY_MANAGER, ERROR_REPORTER, fAmpSymbol, fAposSymbol, fCharRefLiteral, fEncodingSymbol, fEntityDepth, fEntityManager, fEntityScanner, fErrorReporter, fGtSymbol, fLtSymbol, fNamespaces, fNotifyCharRefs, fParserSettings, fQuotSymbol, fReportEntity, fResourceIdentifier, fScanningAttribute, fStandaloneSymbol, fSymbolTable, fValidation, fVersionSymbol, NOTIFY_CHAR_REFS, PARSER_SETTINGS, SYMBOL_TABLE, VALIDATION
-
-
Constructor Summary
Constructors Constructor Description XMLDocumentScannerImpl()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected XMLDocumentFragmentScannerImpl.Dispatcher
createContentDispatcher()
Creates a content dispatcher.void
endEntity(String name, Augmentations augs)
This method notifies the end of an entity.Boolean
getFeatureDefault(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.Object
getPropertyDefault(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.String[]
getRecognizedFeatures()
Returns a list of feature identifiers that are recognized by this component.String[]
getRecognizedProperties()
Returns a list of property identifiers that are recognized by this component.protected String
getScannerStateName(int state)
Returns the scanner state name.void
reset(XMLComponentManager componentManager)
Resets the component.protected boolean
scanDoctypeDecl()
Scans a doctype declaration.void
setFeature(String featureId, boolean state)
Sets the state of a feature.void
setInputSource(XMLInputSource inputSource)
Sets the input source.void
setProperty(String propertyId, Object value)
Sets the value of a property.void
startEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs)
This method notifies of the start of an entity.-
Methods inherited from class org.smooks.engine.delivery.sax.ng.org.apache.xerces.impl.XMLDocumentFragmentScannerImpl
getDispatcherName, getDocumentHandler, handleEndElement, scanAttribute, scanCDATASection, scanCharReference, scanComment, scanContent, scanDocument, scanEndElement, scanEntityReference, scanPIData, scanStartElement, scanStartElementAfterName, scanStartElementName, scanXMLDeclOrTextDecl, setDispatcher, setDocumentHandler, setScannerState
-
Methods inherited from class org.smooks.engine.delivery.sax.ng.org.apache.xerces.impl.XMLScanner
getFeature, getVersionNotSupportedKey, isInvalid, isInvalidLiteral, isUnchangedByNormalization, isValidNameChar, isValidNameStartChar, isValidNameStartHighSurrogate, isValidNCName, normalizeWhitespace, normalizeWhitespace, reportFatalError, reset, scanAttributeValue, scanCharReferenceValue, scanComment, scanExternalID, scanPI, scanPseudoAttribute, scanPubidLiteral, scanSurrogates, scanXMLDeclOrTextDecl, versionSupported
-
-
-
-
Field Detail
-
SCANNER_STATE_XML_DECL
protected static final int SCANNER_STATE_XML_DECL
Scanner state: XML declaration.- See Also:
- Constant Field Values
-
SCANNER_STATE_PROLOG
protected static final int SCANNER_STATE_PROLOG
Scanner state: prolog.- See Also:
- Constant Field Values
-
SCANNER_STATE_TRAILING_MISC
protected static final int SCANNER_STATE_TRAILING_MISC
Scanner state: trailing misc.- See Also:
- Constant Field Values
-
SCANNER_STATE_DTD_INTERNAL_DECLS
protected static final int SCANNER_STATE_DTD_INTERNAL_DECLS
Scanner state: DTD internal declarations.- See Also:
- Constant Field Values
-
SCANNER_STATE_DTD_EXTERNAL
protected static final int SCANNER_STATE_DTD_EXTERNAL
Scanner state: open DTD external subset.- See Also:
- Constant Field Values
-
SCANNER_STATE_DTD_EXTERNAL_DECLS
protected static final int SCANNER_STATE_DTD_EXTERNAL_DECLS
Scanner state: DTD external declarations.- See Also:
- Constant Field Values
-
LOAD_EXTERNAL_DTD
protected static final String LOAD_EXTERNAL_DTD
Feature identifier: load external DTD.- See Also:
- Constant Field Values
-
DISALLOW_DOCTYPE_DECL_FEATURE
protected static final String DISALLOW_DOCTYPE_DECL_FEATURE
Feature identifier: load external DTD.- See Also:
- Constant Field Values
-
DTD_SCANNER
protected static final String DTD_SCANNER
Property identifier: DTD scanner.- See Also:
- Constant Field Values
-
VALIDATION_MANAGER
protected static final String VALIDATION_MANAGER
property identifier: ValidationManager- See Also:
- Constant Field Values
-
NAMESPACE_CONTEXT
protected static final String NAMESPACE_CONTEXT
property identifier: NamespaceContext- See Also:
- Constant Field Values
-
fDTDScanner
protected XMLDTDScanner fDTDScanner
DTD scanner.
-
fValidationManager
protected ValidationManager fValidationManager
Validation manager .
-
fScanningDTD
protected boolean fScanningDTD
Scanning DTD.
-
fDoctypeName
protected String fDoctypeName
Doctype name.
-
fDoctypePublicId
protected String fDoctypePublicId
Doctype declaration public identifier.
-
fDoctypeSystemId
protected String fDoctypeSystemId
Doctype declaration system identifier.
-
fNamespaceContext
protected NamespaceContext fNamespaceContext
Namespace support.
-
fLoadExternalDTD
protected boolean fLoadExternalDTD
Load external DTD.
-
fDisallowDoctype
protected boolean fDisallowDoctype
Disallow doctype declaration.
-
fSeenDoctypeDecl
protected boolean fSeenDoctypeDecl
Seen doctype declaration.
-
fXMLDeclDispatcher
protected final XMLDocumentFragmentScannerImpl.Dispatcher fXMLDeclDispatcher
XML declaration dispatcher.
-
fPrologDispatcher
protected final XMLDocumentFragmentScannerImpl.Dispatcher fPrologDispatcher
Prolog dispatcher.
-
fDTDDispatcher
protected final XMLDocumentFragmentScannerImpl.Dispatcher fDTDDispatcher
DTD dispatcher.
-
fTrailingMiscDispatcher
protected final XMLDocumentFragmentScannerImpl.Dispatcher fTrailingMiscDispatcher
Trailing miscellaneous section dispatcher.
-
-
Method Detail
-
setInputSource
public void setInputSource(XMLInputSource inputSource) throws IOException
Sets the input source.- Specified by:
setInputSource
in interfaceXMLDocumentScanner
- Overrides:
setInputSource
in classXMLDocumentFragmentScannerImpl
- Parameters:
inputSource
- The input source.- Throws:
IOException
- Thrown on i/o error.
-
reset
public void reset(XMLComponentManager componentManager) throws 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 interfaceXMLComponent
- Overrides:
reset
in classXMLDocumentFragmentScannerImpl
- 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.XMLConfigurationException
-
getRecognizedFeatures
public 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 interfaceXMLComponent
- Overrides:
getRecognizedFeatures
in classXMLDocumentFragmentScannerImpl
-
setFeature
public void setFeature(String featureId, boolean state) throws 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 interfaceXMLComponent
- Overrides:
setFeature
in classXMLDocumentFragmentScannerImpl
- 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.XMLConfigurationException
- Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.
-
getRecognizedProperties
public 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 interfaceXMLComponent
- Overrides:
getRecognizedProperties
in classXMLDocumentFragmentScannerImpl
-
setProperty
public void setProperty(String propertyId, Object value) throws 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 interfaceXMLComponent
- Overrides:
setProperty
in classXMLDocumentFragmentScannerImpl
- 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.XMLConfigurationException
- Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.
-
getFeatureDefault
public Boolean getFeatureDefault(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 interfaceXMLComponent
- Overrides:
getFeatureDefault
in classXMLDocumentFragmentScannerImpl
- Parameters:
featureId
- The feature identifier.- Since:
- Xerces 2.2.0
-
getPropertyDefault
public Object getPropertyDefault(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 interfaceXMLComponent
- Overrides:
getPropertyDefault
in classXMLDocumentFragmentScannerImpl
- Parameters:
propertyId
- The property identifier.- Since:
- Xerces 2.2.0
-
startEntity
public void startEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs) throws 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 interfaceXMLEntityHandler
- Overrides:
startEntity
in classXMLDocumentFragmentScannerImpl
- 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).augs
- Additional information that may include infoset augmentations- Throws:
XNIException
- Thrown by handler to signal an error.
-
endEntity
public void endEntity(String name, Augmentations augs) throws 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 interfaceXMLEntityHandler
- Overrides:
endEntity
in classXMLDocumentFragmentScannerImpl
- Parameters:
name
- The name of the entity.augs
- Additional information that may include infoset augmentations- Throws:
XNIException
- Thrown by handler to signal an error.
-
createContentDispatcher
protected XMLDocumentFragmentScannerImpl.Dispatcher createContentDispatcher()
Creates a content dispatcher.- Overrides:
createContentDispatcher
in classXMLDocumentFragmentScannerImpl
-
scanDoctypeDecl
protected boolean scanDoctypeDecl() throws IOException, XNIException
Scans a doctype declaration.- Throws:
IOException
XNIException
-
getScannerStateName
protected String getScannerStateName(int state)
Returns the scanner state name.- Overrides:
getScannerStateName
in classXMLDocumentFragmentScannerImpl
-
-