Package org.apache.xerces.impl
Class XMLDTDScannerImpl
- java.lang.Object
-
- org.apache.xerces.impl.XMLScanner
-
- org.apache.xerces.impl.XMLDTDScannerImpl
-
- All Implemented Interfaces:
XMLEntityHandler,org.apache.xerces.xni.parser.XMLComponent,org.apache.xerces.xni.parser.XMLDTDContentModelSource,org.apache.xerces.xni.parser.XMLDTDScanner,org.apache.xerces.xni.parser.XMLDTDSource
- Direct Known Subclasses:
XML11DTDScannerImpl
public class XMLDTDScannerImpl extends XMLScanner implements org.apache.xerces.xni.parser.XMLDTDScanner, org.apache.xerces.xni.parser.XMLComponent, XMLEntityHandler
This class is responsible for scanning the declarations found in the internal and external subsets of a DTD in an XML document. The scanner acts as the sources for the DTD information which is communicated to the DTD handlers.This component requires the following features and properties from the component manager that uses it:
- http://xml.org/sax/features/validation
- http://apache.org/xml/features/scanner/notify-char-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
INTERNAL:
- Usage of this class is not supported. It may be altered or removed at any time.
- Version:
- $Id: XMLDTDScannerImpl.java 1514806 2013-08-16 17:29:02Z mrglavas $
- Author:
- Arnaud Le Hors, IBM, Andy Clark, IBM, Glenn Marcy, IBM, Eric Ye, IBM
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.xerces.xni.XMLDTDContentModelHandlerfDTDContentModelHandlerDTD content model handler.protected org.apache.xerces.xni.XMLDTDHandlerfDTDHandlerDTD handler.protected intfScannerStateScanner state.protected booleanfSeenExternalDTDSeen external DTD.protected booleanfSeenPEReferencesSeen a parameter entity reference.protected booleanfStandaloneStandalone.protected static intSCANNER_STATE_END_OF_INPUTScanner state: end of input.protected static intSCANNER_STATE_MARKUP_DECLScanner state: markup declaration.protected static intSCANNER_STATE_TEXT_DECLScanner state: text declaration.-
Fields inherited from class 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, NAMESPACES, NOTIFY_CHAR_REFS, PARSER_SETTINGS, SYMBOL_TABLE, VALIDATION
-
-
Constructor Summary
Constructors Constructor Description XMLDTDScannerImpl()Default constructor.XMLDTDScannerImpl(SymbolTable symbolTable, XMLErrorReporter errorReporter, XMLEntityManager entityManager)Constructor for he use of non-XMLComponentManagers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidendEntity(java.lang.String name, org.apache.xerces.xni.Augmentations augs)This method notifies the end of an entity.org.apache.xerces.xni.XMLDTDContentModelHandlergetDTDContentModelHandler()getDTDContentModelHandlerorg.apache.xerces.xni.XMLDTDHandlergetDTDHandler()getDTDHandlerjava.lang.BooleangetFeatureDefault(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.java.lang.ObjectgetPropertyDefault(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.voidreset()voidreset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)resetprotected java.lang.StringscanAttDefaultDecl(java.lang.String elName, java.lang.String atName, java.lang.String type, org.apache.xerces.xni.XMLString defaultVal, org.apache.xerces.xni.XMLString nonNormalizedDefaultVal)Scans an attribute default declarationprotected voidscanAttlistDecl()Scans an attlist declarationprotected voidscanComment()Scans a comment.protected booleanscanDecls(boolean complete)Dispatch an XML "event".booleanscanDTDExternalSubset(boolean complete)Scans the external subset of the document.booleanscanDTDInternalSubset(boolean complete, boolean standalone, boolean hasExternalSubset)Scans the internal subset of the document.protected voidscanElementDecl()Scans an element declarationprotected intscanEntityValue(org.apache.xerces.xni.XMLString value, org.apache.xerces.xni.XMLString nonNormalizedValue)Scans an entity value.protected booleanscanningInternalSubset()protected voidscanPIData(java.lang.String target, org.apache.xerces.xni.XMLString data)Scans a processing data.protected booleanscanTextDecl()Dispatch an XML "event".voidsetDTDContentModelHandler(org.apache.xerces.xni.XMLDTDContentModelHandler dtdContentModelHandler)setDTDContentModelHandlervoidsetDTDHandler(org.apache.xerces.xni.XMLDTDHandler dtdHandler)setDTDHandlervoidsetInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)Sets the input source.protected voidsetScannerState(int state)Sets the scanner state.voidstartEntity(java.lang.String name, org.apache.xerces.xni.XMLResourceIdentifier identifier, java.lang.String encoding, org.apache.xerces.xni.Augmentations augs)This method notifies of the start of an entity.protected java.lang.StringstartPE(java.lang.String name, boolean literal)start a parameter entity dealing with the textdecl if there is any-
Methods inherited from class org.apache.xerces.impl.XMLScanner
getFeature, getVersionNotSupportedKey, isInvalid, isInvalidLiteral, isUnchangedByNormalization, isValidNameChar, isValidNameStartChar, isValidNameStartHighSurrogate, isValidNCName, normalizeWhitespace, normalizeWhitespace, reportFatalError, scanAttributeValue, scanCharReferenceValue, scanComment, scanExternalID, scanPI, scanPseudoAttribute, scanPubidLiteral, scanSurrogates, scanXMLDeclOrTextDecl, setFeature, setProperty, versionSupported
-
-
-
-
Field Detail
-
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_TEXT_DECL
protected static final int SCANNER_STATE_TEXT_DECL
Scanner state: text declaration.- See Also:
- Constant Field Values
-
SCANNER_STATE_MARKUP_DECL
protected static final int SCANNER_STATE_MARKUP_DECL
Scanner state: markup declaration.- See Also:
- Constant Field Values
-
fDTDHandler
protected org.apache.xerces.xni.XMLDTDHandler fDTDHandler
DTD handler.
-
fDTDContentModelHandler
protected org.apache.xerces.xni.XMLDTDContentModelHandler fDTDContentModelHandler
DTD content model handler.
-
fScannerState
protected int fScannerState
Scanner state.
-
fStandalone
protected boolean fStandalone
Standalone.
-
fSeenExternalDTD
protected boolean fSeenExternalDTD
Seen external DTD.
-
fSeenPEReferences
protected boolean fSeenPEReferences
Seen a parameter entity reference.
-
-
Constructor Detail
-
XMLDTDScannerImpl
public XMLDTDScannerImpl()
Default constructor.
-
XMLDTDScannerImpl
public XMLDTDScannerImpl(SymbolTable symbolTable, XMLErrorReporter errorReporter, XMLEntityManager entityManager)
Constructor for he use of non-XMLComponentManagers.
-
-
Method Detail
-
setInputSource
public void setInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource) throws java.io.IOExceptionSets the input source.- Specified by:
setInputSourcein interfaceorg.apache.xerces.xni.parser.XMLDTDScanner- Parameters:
inputSource- The input source or null.- Throws:
java.io.IOException- Thrown on i/o error.
-
scanDTDExternalSubset
public boolean scanDTDExternalSubset(boolean complete) throws java.io.IOException, org.apache.xerces.xni.XNIExceptionScans the external subset of the document.- Specified by:
scanDTDExternalSubsetin interfaceorg.apache.xerces.xni.parser.XMLDTDScanner- 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.IOExceptionorg.apache.xerces.xni.XNIException
-
scanDTDInternalSubset
public boolean scanDTDInternalSubset(boolean complete, boolean standalone, boolean hasExternalSubset) throws java.io.IOException, org.apache.xerces.xni.XNIExceptionScans the internal subset of the document.- Specified by:
scanDTDInternalSubsetin interfaceorg.apache.xerces.xni.parser.XMLDTDScanner- 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.standalone- True if the document was specified as standalone. This value is important for verifying certain well-formedness constraints.hasExternalSubset- True if the document has an external DTD. This allows the scanner to properly notify the handler of the end of the DTD in the absence of an external subset.- Returns:
- True if there is more to scan, false otherwise.
- Throws:
java.io.IOExceptionorg.apache.xerces.xni.XNIException
-
reset
public void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager) throws org.apache.xerces.xni.parser.XMLConfigurationExceptionreset- Specified by:
resetin interfaceorg.apache.xerces.xni.parser.XMLComponent- Overrides:
resetin classXMLScanner- Parameters:
componentManager-- Throws:
org.apache.xerces.xni.parser.XMLConfigurationException
-
reset
public void reset()
- Overrides:
resetin classXMLScanner
-
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:
getRecognizedFeaturesin interfaceorg.apache.xerces.xni.parser.XMLComponent
-
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:
getRecognizedPropertiesin interfaceorg.apache.xerces.xni.parser.XMLComponent
-
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:
getFeatureDefaultin interfaceorg.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:
getPropertyDefaultin interfaceorg.apache.xerces.xni.parser.XMLComponent- Parameters:
propertyId- The property identifier.- Since:
- Xerces 2.2.0
-
setDTDHandler
public void setDTDHandler(org.apache.xerces.xni.XMLDTDHandler dtdHandler)
setDTDHandler- Specified by:
setDTDHandlerin interfaceorg.apache.xerces.xni.parser.XMLDTDSource- Parameters:
dtdHandler-
-
getDTDHandler
public org.apache.xerces.xni.XMLDTDHandler getDTDHandler()
getDTDHandler- Specified by:
getDTDHandlerin interfaceorg.apache.xerces.xni.parser.XMLDTDSource- Returns:
- the XMLDTDHandler
-
setDTDContentModelHandler
public void setDTDContentModelHandler(org.apache.xerces.xni.XMLDTDContentModelHandler dtdContentModelHandler)
setDTDContentModelHandler- Specified by:
setDTDContentModelHandlerin interfaceorg.apache.xerces.xni.parser.XMLDTDContentModelSource- Parameters:
dtdContentModelHandler-
-
getDTDContentModelHandler
public org.apache.xerces.xni.XMLDTDContentModelHandler getDTDContentModelHandler()
getDTDContentModelHandler- Specified by:
getDTDContentModelHandlerin interfaceorg.apache.xerces.xni.parser.XMLDTDContentModelSource- Returns:
- XMLDTDContentModelHandler
-
startEntity
public void startEntity(java.lang.String name, org.apache.xerces.xni.XMLResourceIdentifier identifier, java.lang.String encoding, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIExceptionThis 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:
startEntityin interfaceXMLEntityHandler- Overrides:
startEntityin classXMLScanner- 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:
org.apache.xerces.xni.XNIException- Thrown by handler to signal an error.
-
endEntity
public void endEntity(java.lang.String name, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIExceptionThis 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:
endEntityin interfaceXMLEntityHandler- Overrides:
endEntityin classXMLScanner- Parameters:
name- The name of the entity.augs- Additional information that may include infoset augmentations- Throws:
org.apache.xerces.xni.XNIException- Thrown by handler to signal an error.
-
setScannerState
protected final void setScannerState(int state)
Sets the scanner state.- Parameters:
state- The new scanner state.
-
scanningInternalSubset
protected final boolean scanningInternalSubset()
-
startPE
protected java.lang.String startPE(java.lang.String name, boolean literal) throws java.io.IOException, org.apache.xerces.xni.XNIExceptionstart a parameter entity dealing with the textdecl if there is any- Parameters:
name- The name of the parameter entity to start (without the '%')literal- Whether this is happening within a literal- Returns:
- The name of the parameter entity (with the '%')
- Throws:
java.io.IOExceptionorg.apache.xerces.xni.XNIException
-
scanTextDecl
protected final boolean scanTextDecl() throws java.io.IOException, org.apache.xerces.xni.XNIExceptionDispatch an XML "event".- Returns:
- true if a TextDecl was scanned.
- Throws:
java.io.IOException- Thrown on i/o error.org.apache.xerces.xni.XNIException- Thrown on parse error.
-
scanPIData
protected final void scanPIData(java.lang.String target, org.apache.xerces.xni.XMLString data) throws java.io.IOException, org.apache.xerces.xni.XNIExceptionScans 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:
scanPIDatain classXMLScanner- Parameters:
target- The PI targetdata- The string to fill in with the data- Throws:
java.io.IOExceptionorg.apache.xerces.xni.XNIException
-
scanComment
protected final void scanComment() throws java.io.IOException, org.apache.xerces.xni.XNIExceptionScans a comment.[15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'Note: Called after scanning past '<!--'
- Throws:
java.io.IOExceptionorg.apache.xerces.xni.XNIException
-
scanElementDecl
protected final void scanElementDecl() throws java.io.IOException, org.apache.xerces.xni.XNIExceptionScans an element declaration[45] elementdecl ::= '<!ELEMENT' S Name S contentspec S? '>' [46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children
Note: Called after scanning past '<!ELEMENT'
- Throws:
java.io.IOExceptionorg.apache.xerces.xni.XNIException
-
scanAttlistDecl
protected final void scanAttlistDecl() throws java.io.IOException, org.apache.xerces.xni.XNIExceptionScans an attlist declaration[52] AttlistDecl ::= '<!ATTLIST' S Name AttDef* S? '>' [53] AttDef ::= S Name S AttType S DefaultDecl
Note: Called after scanning past '<!ATTLIST'
- Throws:
java.io.IOExceptionorg.apache.xerces.xni.XNIException
-
scanAttDefaultDecl
protected final java.lang.String scanAttDefaultDecl(java.lang.String elName, java.lang.String atName, java.lang.String type, org.apache.xerces.xni.XMLString defaultVal, org.apache.xerces.xni.XMLString nonNormalizedDefaultVal) throws java.io.IOException, org.apache.xerces.xni.XNIExceptionScans an attribute default declaration[60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)- Parameters:
elName-atName- The name of the attribute being scanned.type-defaultVal- The string to fill in with the default value.nonNormalizedDefaultVal-- Throws:
java.io.IOExceptionorg.apache.xerces.xni.XNIException
-
scanEntityValue
protected final int scanEntityValue(org.apache.xerces.xni.XMLString value, org.apache.xerces.xni.XMLString nonNormalizedValue) throws java.io.IOException, org.apache.xerces.xni.XNIExceptionScans an entity value.
Note: This method uses fString, fStringBuffer (through the use of scanCharReferenceValue), and fStringBuffer2, anything in them at the time of calling is lost.
- Parameters:
value- The string to fill in with the value.nonNormalizedValue- The string to fill in with the non-normalized value.- Returns:
- Count of direct and indirect references to parameter entities in the value of the entity.
- Throws:
java.io.IOExceptionorg.apache.xerces.xni.XNIException
-
scanDecls
protected final boolean scanDecls(boolean complete) throws java.io.IOException, org.apache.xerces.xni.XNIExceptionDispatch an XML "event".- Parameters:
complete- True if this method is intended to scan and dispatch as much as possible.- Returns:
- True if there is more to scan.
- Throws:
java.io.IOException- Thrown on i/o error.org.apache.xerces.xni.XNIException- Thrown on parse error.
-
-