org.apache.xerces.framework
Class XMLDTDScanner

java.lang.Object
  |
  +--org.apache.xerces.framework.XMLDTDScanner

public final class XMLDTDScanner
extends java.lang.Object

Default implementation of an XML DTD scanner. Clients who wish to scan a DTD should implement XMLDTDScanner.EventHandler to provide the desired behavior when various DTD components are encountered. To process the DTD, the client application should follow the following sequence:

  1. call scanDocTypeDecl() to scan the DOCTYPE declaration
  2. call getReadingExternalEntity() to determine if scanDocTypeDecl found an external subset
  3. if scanning an external subset, call scanDecls(true) to process the external subset

Version:
 
See Also:
XMLDTDScanner.EventHandler

Inner Class Summary
static interface XMLDTDScanner.EventHandler
          This interface must be implemented by the users of the XMLDTDScanner class.
 
Constructor Summary
XMLDTDScanner(XMLDTDScanner.EventHandler eventHandler, StringPool stringPool, XMLErrorReporter errorReporter, XMLEntityHandler entityHandler, XMLEntityHandler.CharBuffer literalData)
           
 
Method Summary
 void endOfInput(int entityNameIndex, boolean moreToFollow)
          Handle the end of input
 boolean getReadingContentSpec()
          Is the scanner reading a ContentSpec?
 boolean getReadingExternalEntity()
          Is the XMLDTDScanner reading from an external entity? This will be true, in particular if there was an external subset
 int markupDepth()
          Report the markup nesting depth.
 int parenDepth()
          Report the parenthesis nesting depth.
 void readerChange(XMLEntityHandler.EntityReader nextReader, int nextReaderId)
          Change readers
 void reset(StringPool stringPool, XMLEntityHandler.CharBuffer literalData)
          Allow XMLDTDScanner to be reused.
 void scanDecls(boolean extSubset)
          Scan markup declarations
 int scanDefaultAttValue(int elementType, int attrName)
          Scan the default value in an attribute declaration
 boolean scanDoctypeDecl()
          This routine is called after the <!DOCTYPE portion of a DOCTYPE line has been called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLDTDScanner

public XMLDTDScanner(XMLDTDScanner.EventHandler eventHandler,
                     StringPool stringPool,
                     XMLErrorReporter errorReporter,
                     XMLEntityHandler entityHandler,
                     XMLEntityHandler.CharBuffer literalData)
Method Detail

getReadingExternalEntity

public boolean getReadingExternalEntity()
Is the XMLDTDScanner reading from an external entity? This will be true, in particular if there was an external subset
Returns:
true if the XMLDTDScanner is reading from an external entity.

getReadingContentSpec

public boolean getReadingContentSpec()
Is the scanner reading a ContentSpec?
Returns:
true if the scanner is reading a ContentSpec

markupDepth

public int markupDepth()
Report the markup nesting depth. This allows a client to perform validation checks for correct markup nesting. This keeps scanning and validation separate.
Returns:
the markup nesting depth

parenDepth

public int parenDepth()
Report the parenthesis nesting depth. This allows a client to perform validation checks for correct parenthesis balancing. This keeps scanning and validation separate.
Returns:
the parenthesis depth

reset

public void reset(StringPool stringPool,
                  XMLEntityHandler.CharBuffer literalData)
           throws java.lang.Exception
Allow XMLDTDScanner to be reused. This method is called from an XMLParser reset method, which passes the StringPool to be used by the reset DTD scanner instance.
Parameters:
stringPool - the string pool to be used by XMLDTDScanner.

readerChange

public void readerChange(XMLEntityHandler.EntityReader nextReader,
                         int nextReaderId)
                  throws java.lang.Exception
Change readers
Parameters:
nextReader - the new reader that the scanner will use
nextReaderId - id of the reader to change to
Throws:
throws - java.lang.Exception

endOfInput

public void endOfInput(int entityNameIndex,
                       boolean moreToFollow)
                throws java.lang.Exception
Handle the end of input
Parameters:
entityName - the handle in the string pool of the name of the entity which has reached end of input
moreToFollow - if true, there is still input left to process in other readers
Throws:
java.lang.Exception -  

scanDoctypeDecl

public boolean scanDoctypeDecl()
                        throws java.lang.Exception
This routine is called after the <!DOCTYPE portion of a DOCTYPE line has been called. scanDocTypeDecl goes onto scan the rest of the DOCTYPE decl. If an internal DTD subset exists, it is scanned. If an external DTD subset exists, scanDocTypeDecl sets up the state necessary to process it.
Returns:
true if successful
Throws:
java.lang.Exception -  

scanDecls

public void scanDecls(boolean extSubset)
               throws java.lang.Exception
Scan markup declarations
Parameters:
extSubset - true if the scanner is scanning an external subset, false if it is scanning an internal subset
Throws:
java.lang.Exception -  

scanDefaultAttValue

public int scanDefaultAttValue(int elementType,
                               int attrName)
                        throws java.lang.Exception
Scan the default value in an attribute declaration
Parameters:
elementType - handle to the element that owns the attribute
attrName - handle in the string pool for the attribute name
Returns:
handle in the string pool for the default attribute value
Throws:
java.lang.Exception -  


Copyright © 1999 Apache XML Project. All Rights Reserved.