Class XMLDocumentScannerImpl

  • All Implemented Interfaces:
    XMLEntityHandler, org.apache.xerces.xni.parser.XMLComponent, org.apache.xerces.xni.parser.XMLDocumentScanner, org.apache.xerces.xni.parser.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

    INTERNAL:

    Usage of this class is not supported. It may be altered or removed at any time.
    Version:
    $Id: XMLDocumentScannerImpl.java 572055 2007-09-02 17:55:43Z mrglavas $
    Author:
    Glenn Marcy, IBM, Andy Clark, IBM, Arnaud Le Hors, IBM, Eric Ye, IBM
    • 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 java.lang.String LOAD_EXTERNAL_DTD
        Feature identifier: load external DTD.
        See Also:
        Constant Field Values
      • DISALLOW_DOCTYPE_DECL_FEATURE

        protected static final java.lang.String DISALLOW_DOCTYPE_DECL_FEATURE
        Feature identifier: load external DTD.
        See Also:
        Constant Field Values
      • DTD_SCANNER

        protected static final java.lang.String DTD_SCANNER
        Property identifier: DTD scanner.
        See Also:
        Constant Field Values
      • VALIDATION_MANAGER

        protected static final java.lang.String VALIDATION_MANAGER
        property identifier: ValidationManager
        See Also:
        Constant Field Values
      • NAMESPACE_CONTEXT

        protected static final java.lang.String NAMESPACE_CONTEXT
        property identifier: NamespaceContext
        See Also:
        Constant Field Values
      • fDTDScanner

        protected org.apache.xerces.xni.parser.XMLDTDScanner fDTDScanner
        DTD scanner.
      • fValidationManager

        protected ValidationManager fValidationManager
        Validation manager .
      • fScanningDTD

        protected boolean fScanningDTD
        Scanning DTD.
      • fDoctypeName

        protected java.lang.String fDoctypeName
        Doctype name.
      • fDoctypePublicId

        protected java.lang.String fDoctypePublicId
        Doctype declaration public identifier.
      • fDoctypeSystemId

        protected java.lang.String fDoctypeSystemId
        Doctype declaration system identifier.
      • fNamespaceContext

        protected org.apache.xerces.xni.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.
    • Constructor Detail

      • XMLDocumentScannerImpl

        public XMLDocumentScannerImpl()
        Default constructor.
    • Method Detail

      • 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
        Overrides:
        setInputSource in class XMLDocumentFragmentScannerImpl
        Parameters:
        inputSource - The input source.
        Throws:
        java.io.IOException - Thrown on i/o error.
      • reset

        public void reset​(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
                   throws org.apache.xerces.xni.parser.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 interface org.apache.xerces.xni.parser.XMLComponent
        Overrides:
        reset in class XMLDocumentFragmentScannerImpl
        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.
        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
        Overrides:
        getRecognizedFeatures in class XMLDocumentFragmentScannerImpl
      • setFeature

        public void setFeature​(java.lang.String featureId,
                               boolean state)
                        throws org.apache.xerces.xni.parser.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 interface org.apache.xerces.xni.parser.XMLComponent
        Overrides:
        setFeature in class XMLDocumentFragmentScannerImpl
        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.
        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.
      • 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
        Overrides:
        getRecognizedProperties in class XMLDocumentFragmentScannerImpl
      • 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. 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 interface org.apache.xerces.xni.parser.XMLComponent
        Overrides:
        setProperty in class XMLDocumentFragmentScannerImpl
        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.
        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.
      • 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
        Overrides:
        getFeatureDefault in class XMLDocumentFragmentScannerImpl
        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
        Overrides:
        getPropertyDefault in class XMLDocumentFragmentScannerImpl
        Parameters:
        propertyId - The property identifier.
        Since:
        Xerces 2.2.0
      • 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.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 interface XMLEntityHandler
        Overrides:
        startEntity in class XMLDocumentFragmentScannerImpl
        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.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 interface XMLEntityHandler
        Overrides:
        endEntity in class XMLDocumentFragmentScannerImpl
        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.
      • scanDoctypeDecl

        protected boolean scanDoctypeDecl()
                                   throws java.io.IOException,
                                          org.apache.xerces.xni.XNIException
        Scans a doctype declaration.
        Throws:
        java.io.IOException
        org.apache.xerces.xni.XNIException