public class

XMLDTDScannerImpl

extends XMLScanner
implements XMLEntityHandler XMLComponent XMLDTDScanner
java.lang.Object
   ↳ org.apache.xerces.impl.XMLScanner
     ↳ org.apache.xerces.impl.XMLDTDScannerImpl
Known Direct Subclasses

Class Overview

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
@xerces.internal

Summary

Constants
int SCANNER_STATE_END_OF_INPUT Scanner state: end of input.
int SCANNER_STATE_MARKUP_DECL Scanner state: markup declaration.
int SCANNER_STATE_TEXT_DECL Scanner state: text declaration.
[Expand]
Inherited Constants
From class org.apache.xerces.impl.XMLScanner
Fields
protected XMLDTDContentModelHandler fDTDContentModelHandler DTD content model handler.
protected XMLDTDHandler fDTDHandler DTD handler.
protected int fScannerState Scanner state.
protected boolean fSeenExternalDTD Seen external DTD.
protected boolean fSeenExternalPE Seen external parameter entity.
protected boolean fStandalone Standalone.
[Expand]
Inherited Fields
From class org.apache.xerces.impl.XMLScanner
Public Constructors
XMLDTDScannerImpl()
Default constructor.
XMLDTDScannerImpl(SymbolTable symbolTable, XMLErrorReporter errorReporter, XMLEntityManager entityManager)
Constructor for he use of non-XMLComponentManagers.
Public Methods
void endEntity(String name, Augmentations augs)
This method notifies the end of an entity.
XMLDTDContentModelHandler getDTDContentModelHandler()
getDTDContentModelHandler
XMLDTDHandler getDTDHandler()
getDTDHandler
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.
void reset(XMLComponentManager componentManager)
reset
void reset()
boolean scanDTDExternalSubset(boolean complete)
Scans the external subset of the document.
boolean scanDTDInternalSubset(boolean complete, boolean standalone, boolean hasExternalSubset)
Scans the internal subset of the document.
void setDTDContentModelHandler(XMLDTDContentModelHandler dtdContentModelHandler)
setDTDContentModelHandler
void setDTDHandler(XMLDTDHandler dtdHandler)
setDTDHandler
void setInputSource(XMLInputSource inputSource)
Sets the input source.
void startEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs)
This method notifies of the start of an entity.
Protected Methods
final String scanAttDefaultDecl(String elName, String atName, String type, XMLString defaultVal, XMLString nonNormalizedDefaultVal)
Scans an attribute default declaration

 [60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)
 
final void scanAttlistDecl()
Scans an attlist declaration

 [52]  AttlistDecl    ::=   '<!ATTLIST' S Name AttDef* S? '>' 
 [53]  AttDef         ::=   S Name S AttType S DefaultDecl 
 

Note: Called after scanning past '<!ATTLIST'

final void scanComment()
Scans a comment.
final boolean scanDecls(boolean complete)
Dispatch an XML "event".
final void scanElementDecl()
Scans an element declaration

 [45]    elementdecl    ::=    '<!ELEMENT' S Name S contentspec S? '>'
 [46]    contentspec    ::=    'EMPTY' | 'ANY' | Mixed | children  
 

Note: Called after scanning past '<!ELEMENT'

final void scanEntityValue(XMLString value, XMLString nonNormalizedValue)
Scans an entity value.
final void scanPIData(String target, XMLString data)
Scans a processing data.
final boolean scanTextDecl()
Dispatch an XML "event".
final boolean scanningInternalSubset()
final void setScannerState(int state)
Sets the scanner state.
void startPE(String name, boolean literal)
start a parameter entity dealing with the textdecl if there is any
[Expand]
Inherited Methods
From class org.apache.xerces.impl.XMLScanner
From class java.lang.Object
From interface org.apache.xerces.impl.XMLEntityHandler
From interface org.apache.xerces.xni.parser.XMLComponent
From interface org.apache.xerces.xni.parser.XMLDTDContentModelSource
From interface org.apache.xerces.xni.parser.XMLDTDScanner
From interface org.apache.xerces.xni.parser.XMLDTDSource

Constants

protected static final int SCANNER_STATE_END_OF_INPUT

Scanner state: end of input.

Constant Value: 0 (0x00000000)

protected static final int SCANNER_STATE_MARKUP_DECL

Scanner state: markup declaration.

Constant Value: 2 (0x00000002)

protected static final int SCANNER_STATE_TEXT_DECL

Scanner state: text declaration.

Constant Value: 1 (0x00000001)

Fields

protected XMLDTDContentModelHandler fDTDContentModelHandler

DTD content model handler.

protected XMLDTDHandler fDTDHandler

DTD handler.

protected int fScannerState

Scanner state.

protected boolean fSeenExternalDTD

Seen external DTD.

protected boolean fSeenExternalPE

Seen external parameter entity.

protected boolean fStandalone

Standalone.

Public Constructors

public XMLDTDScannerImpl ()

Default constructor.

public XMLDTDScannerImpl (SymbolTable symbolTable, XMLErrorReporter errorReporter, XMLEntityManager entityManager)

Constructor for he use of non-XMLComponentManagers.

Public Methods

public void endEntity (String name, Augmentations augs)

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.

Parameters
name The name of the entity.
augs Additional information that may include infoset augmentations
Throws
XNIException Thrown by handler to signal an error.

public XMLDTDContentModelHandler getDTDContentModelHandler ()

getDTDContentModelHandler

Returns
  • XMLDTDContentModelHandler

public XMLDTDHandler getDTDHandler ()

getDTDHandler

Returns
  • the XMLDTDHandler

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.

Parameters
featureId The feature identifier.

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.

Parameters
propertyId The property identifier.

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.

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.

public void reset (XMLComponentManager componentManager)

reset

Parameters
componentManager The component manager.

public void reset ()

public boolean scanDTDExternalSubset (boolean complete)

Scans the external subset of the document.

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.

public boolean scanDTDInternalSubset (boolean complete, boolean standalone, boolean hasExternalSubset)

Scans the internal subset of the document.

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.

public void setDTDContentModelHandler (XMLDTDContentModelHandler dtdContentModelHandler)

setDTDContentModelHandler

public void setDTDHandler (XMLDTDHandler dtdHandler)

setDTDHandler

public void setInputSource (XMLInputSource inputSource)

Sets the input source.

Parameters
inputSource The input source or null.
Throws
IOException Thrown on i/o error.

public void startEntity (String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs)

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.

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.

Protected Methods

protected final String scanAttDefaultDecl (String elName, String atName, String type, XMLString defaultVal, XMLString nonNormalizedDefaultVal)

Scans an attribute default declaration

 [60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)
 

Parameters
atName The name of the attribute being scanned.
defaultVal The string to fill in with the default value.

protected final void scanAttlistDecl ()

Scans an attlist declaration

 [52]  AttlistDecl    ::=   '<!ATTLIST' S Name AttDef* S? '>' 
 [53]  AttDef         ::=   S Name S AttType S DefaultDecl 
 

Note: Called after scanning past '<!ATTLIST'

protected final void scanComment ()

Scans a comment.

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

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

protected final boolean scanDecls (boolean complete)

Dispatch 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
IOException Thrown on i/o error.
XNIException Thrown on parse error.

protected final void scanElementDecl ()

Scans an element declaration

 [45]    elementdecl    ::=    '<!ELEMENT' S Name S contentspec S? '>'
 [46]    contentspec    ::=    'EMPTY' | 'ANY' | Mixed | children  
 

Note: Called after scanning past '<!ELEMENT'

protected final void scanEntityValue (XMLString value, XMLString nonNormalizedValue)

Scans an entity value.

Parameters
value The string to fill in with the value.
nonNormalizedValue The string to fill in with the non-normalized value. Note: This method uses fString, fStringBuffer (through the use of scanCharReferenceValue), and fStringBuffer2, anything in them at the time of calling is lost.

protected final void scanPIData (String target, XMLString data)

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)

Parameters
target The PI target
data The string to fill in with the data

protected final boolean scanTextDecl ()

Dispatch an XML "event".

Returns
  • true if a TextDecl was scanned.
Throws
IOException Thrown on i/o error.
XNIException Thrown on parse error.

protected final boolean scanningInternalSubset ()

protected final void setScannerState (int state)

Sets the scanner state.

Parameters
state The new scanner state.

protected void startPE (String name, boolean literal)

start 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