org.apache.xerces.impl
Class XMLVersionDetector

java.lang.Object
  |
  +--org.apache.xerces.impl.XMLVersionDetector
All Implemented Interfaces:
org.apache.xerces.xni.parser.XMLComponent, org.apache.xerces.xni.parser.XMLDocumentScanner, org.apache.xerces.xni.parser.XMLDocumentSource, org.apache.xerces.xni.parser.XMLDTDContentModelSource, org.apache.xerces.xni.parser.XMLDTDScanner, org.apache.xerces.xni.parser.XMLDTDSource

public class XMLVersionDetector
extends java.lang.Object
implements org.apache.xerces.xni.parser.XMLComponent, org.apache.xerces.xni.parser.XMLDocumentScanner, org.apache.xerces.xni.parser.XMLDTDScanner

This is not a full-function scanner; its sole job is to figure out the version of the document we're scanning, and create the correct document scanner, DTD scanner and entity scanner to deal with it. Any configuration that may parse documents from different versions of XML should place this object first in both the maqin and DTD pipelines, and take care to reset it in that position when it initiates a new parse.

Version:
$Id: XMLVersionDetector.java,v 1.3 2003/01/24 17:28:35 neilg Exp $
Author:
Neil Graham, IBM

Field Summary
protected static java.lang.String DTD_PROCESSOR_PROPERTY
          Property identifier: DTD processor.
protected static java.lang.String DTD_SCANNER_PROPERTY
          Property identifier: DTD scanner.
protected static java.lang.String DTD_VALIDATOR_PROPERTY
          Property identifier: DTD validator.
protected static java.lang.String ENTITY_MANAGER
          Property identifier: entity manager.
protected static java.lang.String ERROR_REPORTER
          Property identifier: error reporter.
protected  org.apache.xerces.xni.parser.XMLComponentManager fComponentManager
           
protected  org.apache.xerces.xni.XMLDocumentHandler fDocumentHandler
           
protected  org.apache.xerces.xni.XMLDTDContentModelHandler fDTDContentModelHandler
           
protected  org.apache.xerces.xni.XMLDTDHandler fDTDHandler
           
protected  XMLEntityManager fEntityManager
          Entity manager.
protected  XMLEntityScanner fEntityScanner
          Entity scanner.
protected  XMLErrorReporter fErrorReporter
          Error reporter.
protected  XMLDocumentScannerImpl fRealDocumentScanner
           
protected  XMLDTDScannerImpl fRealDTDScanner
           
protected  SymbolTable fSymbolTable
          Symbol table.
protected static java.lang.String fVersionSymbol
          Symbol: "version".
protected  XMLDocumentScannerImpl fXML10DocScanner
           
protected  XMLDTDScannerImpl fXML10DTDScanner
           
protected  XML11DocumentScannerImpl fXML11DocScanner
           
protected  XML11DTDProcessor fXML11DTDProcessor
           
protected  XML11DTDScannerImpl fXML11DTDScanner
           
protected  XML11DTDValidator fXML11DTDValidator
           
protected  XML11NamespaceBinder fXML11NamespaceBinder
           
protected static java.lang.String fXMLSymbol
           
protected static java.lang.String NAMESPACE_BINDER_PROPERTY
          Property identifier: namespace binder.
protected static java.lang.String SYMBOL_TABLE
          Property identifier: symbol table.
 
Constructor Summary
XMLVersionDetector()
           
 
Method Summary
 org.apache.xerces.xni.XMLDocumentHandler getDocumentHandler()
          Returns the document handler
 org.apache.xerces.xni.XMLDTDContentModelHandler getDTDContentModelHandler()
          Returns the DTD content model handler.
 org.apache.xerces.xni.XMLDTDHandler getDTDHandler()
          Returns the DTD handler.
 boolean getFeature(java.lang.String featureId)
           
 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.
 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.
 void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
          Resets the component.
 boolean scanDocument(boolean complete)
          Scans a document.
 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 setDocumentHandler(org.apache.xerces.xni.XMLDocumentHandler documentHandler)
          setDocumentHandler
 void setDTDContentModelHandler(org.apache.xerces.xni.XMLDTDContentModelHandler handler)
          Sets the DTD content model handler.
 void setDTDHandler(org.apache.xerces.xni.XMLDTDHandler handler)
          Sets the DTD handler.
 void setFeature(java.lang.String featureId, boolean value)
          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 during parsing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYMBOL_TABLE

protected static final java.lang.String SYMBOL_TABLE
Property identifier: symbol table.

ERROR_REPORTER

protected static final java.lang.String ERROR_REPORTER
Property identifier: error reporter.

ENTITY_MANAGER

protected static final java.lang.String ENTITY_MANAGER
Property identifier: entity manager.

DTD_SCANNER_PROPERTY

protected static final java.lang.String DTD_SCANNER_PROPERTY
Property identifier: DTD scanner.

DTD_VALIDATOR_PROPERTY

protected static final java.lang.String DTD_VALIDATOR_PROPERTY
Property identifier: DTD validator.

DTD_PROCESSOR_PROPERTY

protected static final java.lang.String DTD_PROCESSOR_PROPERTY
Property identifier: DTD processor.

NAMESPACE_BINDER_PROPERTY

protected static final java.lang.String NAMESPACE_BINDER_PROPERTY
Property identifier: namespace binder.

fSymbolTable

protected SymbolTable fSymbolTable
Symbol table.

fErrorReporter

protected XMLErrorReporter fErrorReporter
Error reporter.

fEntityManager

protected XMLEntityManager fEntityManager
Entity manager.

fEntityScanner

protected XMLEntityScanner fEntityScanner
Entity scanner.

fComponentManager

protected org.apache.xerces.xni.parser.XMLComponentManager fComponentManager

fDocumentHandler

protected org.apache.xerces.xni.XMLDocumentHandler fDocumentHandler

fDTDHandler

protected org.apache.xerces.xni.XMLDTDHandler fDTDHandler

fDTDContentModelHandler

protected org.apache.xerces.xni.XMLDTDContentModelHandler fDTDContentModelHandler

fRealDocumentScanner

protected XMLDocumentScannerImpl fRealDocumentScanner

fRealDTDScanner

protected XMLDTDScannerImpl fRealDTDScanner

fXML10DocScanner

protected XMLDocumentScannerImpl fXML10DocScanner

fXML10DTDScanner

protected XMLDTDScannerImpl fXML10DTDScanner

fXML11DocScanner

protected XML11DocumentScannerImpl fXML11DocScanner

fXML11DTDScanner

protected XML11DTDScannerImpl fXML11DTDScanner

fXML11DTDValidator

protected XML11DTDValidator fXML11DTDValidator

fXML11DTDProcessor

protected XML11DTDProcessor fXML11DTDProcessor

fXML11NamespaceBinder

protected XML11NamespaceBinder fXML11NamespaceBinder

fVersionSymbol

protected static final java.lang.String fVersionSymbol
Symbol: "version".

fXMLSymbol

protected static final java.lang.String fXMLSymbol
Constructor Detail

XMLVersionDetector

public XMLVersionDetector()
Method Detail

reset

public void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
           throws org.apache.xerces.xni.parser.XMLConfigurationException
Description copied from interface: org.apache.xerces.xni.parser.XMLComponent
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
Parameters:
componentManager - The component manager.
Throws:
SAXException - Throws exception if required features and properties cannot be found.

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 during parsing.
Specified by:
setProperty in interface org.apache.xerces.xni.parser.XMLComponent
Parameters:
propertyId -  
value -  

setFeature

public void setFeature(java.lang.String featureId,
                       boolean value)
                throws org.apache.xerces.xni.parser.XMLConfigurationException
Description copied from interface: org.apache.xerces.xni.parser.XMLComponent
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
Following copied from interface: org.apache.xerces.xni.parser.XMLComponent
Parameters:
featureId - The feature identifier.
state - The state of the feature.
Throws:
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.

getFeature

public boolean getFeature(java.lang.String featureId)
                   throws org.apache.xerces.xni.parser.XMLConfigurationException

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

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

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

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.

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

setDTDContentModelHandler

public void setDTDContentModelHandler(org.apache.xerces.xni.XMLDTDContentModelHandler handler)
Sets the DTD content model handler.
Specified by:
setDTDContentModelHandler in interface org.apache.xerces.xni.parser.XMLDTDContentModelSource

getDTDContentModelHandler

public org.apache.xerces.xni.XMLDTDContentModelHandler getDTDContentModelHandler()
Returns the DTD content model handler.
Specified by:
getDTDContentModelHandler in interface org.apache.xerces.xni.parser.XMLDTDContentModelSource

setDTDHandler

public void setDTDHandler(org.apache.xerces.xni.XMLDTDHandler handler)
Sets the DTD handler.
Specified by:
setDTDHandler in interface org.apache.xerces.xni.parser.XMLDTDSource

getDTDHandler

public org.apache.xerces.xni.XMLDTDHandler getDTDHandler()
Returns the DTD handler.
Specified by:
getDTDHandler in interface org.apache.xerces.xni.parser.XMLDTDSource

scanDTDInternalSubset

public boolean scanDTDInternalSubset(boolean complete,
                                     boolean standalone,
                                     boolean hasExternalSubset)
                              throws java.io.IOException,
                                     org.apache.xerces.xni.XNIException
Scans the internal subset of the document.
Specified by:
scanDTDInternalSubset in interface org.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.
hasExternalDTD - 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.

scanDTDExternalSubset

public boolean scanDTDExternalSubset(boolean complete)
                              throws java.io.IOException,
                                     org.apache.xerces.xni.XNIException
Scans the external subset of the document.
Specified by:
scanDTDExternalSubset in interface org.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.


Copyright © 1999-2003 Apache XML Project. All Rights Reserved.