Class XMLNSDocumentScannerImpl

  • All Implemented Interfaces:
    XMLEntityHandler, org.apache.xerces.xni.parser.XMLComponent, org.apache.xerces.xni.parser.XMLDocumentScanner, org.apache.xerces.xni.parser.XMLDocumentSource

    public class XMLNSDocumentScannerImpl
    extends XMLDocumentScannerImpl
    The scanner acts as the source for the document information which is communicated to the document handler. This class scans an XML document, checks if document has a DTD, and if DTD is not found the scanner will remove the DTD Validator from the pipeline and perform namespace binding. Note: This scanner should only be used when the namespace processing is on!

    This component requires the following features and properties from the component manager that uses it:

    • http://xml.org/sax/features/namespaces {true} -- if the value of this feature is set to false this scanner must not be used.
    • 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: XMLNSDocumentScannerImpl.java 495747 2007-01-12 21:48:00Z mrglavas $
    Author:
    Elena Litani, IBM
    • Field Detail

      • fBindNamespaces

        protected boolean fBindNamespaces
        If is true, the dtd validator is no longer in the pipeline and the scanner should bind namespaces
      • fPerformValidation

        protected boolean fPerformValidation
        If validating parser, make sure we report an error in the scanner if DTD grammar is missing.
    • Constructor Detail

      • XMLNSDocumentScannerImpl

        public XMLNSDocumentScannerImpl()
    • Method Detail

      • setDTDValidator

        public void setDTDValidator​(XMLDTDValidatorFilter dtdValidator)
        The scanner is responsible for removing DTD validator from the pipeline if it is not needed.
        Parameters:
        dtdValidator - The DTDValidator
      • scanStartElement

        protected boolean scanStartElement()
                                    throws java.io.IOException,
                                           org.apache.xerces.xni.XNIException
        Scans a start element. This method will handle the binding of namespace information and notifying the handler of the start of the element.

         [44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
         [40] STag ::= '<' Name (S Attribute)* S? '>'
         

        Note: This method assumes that the leading '<' character has been consumed.

        Note: This method uses the fElementQName and fAttributes variables. The contents of these variables will be destroyed. The caller should copy important information out of these variables before calling this method.

        Overrides:
        scanStartElement in class XMLDocumentFragmentScannerImpl
        Returns:
        True if element is empty. (i.e. It matches production [44].
        Throws:
        java.io.IOException
        org.apache.xerces.xni.XNIException
      • scanStartElementName

        protected void scanStartElementName()
                                     throws java.io.IOException,
                                            org.apache.xerces.xni.XNIException
        Scans the name of an element in a start or empty tag.
        Overrides:
        scanStartElementName in class XMLDocumentFragmentScannerImpl
        Throws:
        java.io.IOException
        org.apache.xerces.xni.XNIException
        See Also:
        scanStartElement()
      • scanStartElementAfterName

        protected boolean scanStartElementAfterName()
                                             throws java.io.IOException,
                                                    org.apache.xerces.xni.XNIException
        Scans the remainder of a start or empty tag after the element name.
        Overrides:
        scanStartElementAfterName in class XMLDocumentFragmentScannerImpl
        Returns:
        True if element is empty.
        Throws:
        java.io.IOException
        org.apache.xerces.xni.XNIException
        See Also:
        scanStartElement()
      • scanAttribute

        protected void scanAttribute​(XMLAttributesImpl attributes)
                              throws java.io.IOException,
                                     org.apache.xerces.xni.XNIException
        Scans an attribute.

         [41] Attribute ::= Name Eq AttValue
         

        Note: This method assumes that the next character on the stream is the first character of the attribute name.

        Note: This method uses the fAttributeQName and fQName variables. The contents of these variables will be destroyed.

        Parameters:
        attributes - The attributes list for the scanned attribute.
        Throws:
        java.io.IOException
        org.apache.xerces.xni.XNIException
      • scanEndElement

        protected int scanEndElement()
                              throws java.io.IOException,
                                     org.apache.xerces.xni.XNIException
        Scans an end element.

         [42] ETag ::= '</' Name S? '>'
         

        Note: This method uses the fElementQName variable. The contents of this variable will be destroyed. The caller should copy the needed information out of this variable before calling this method.

        Overrides:
        scanEndElement in class XMLDocumentFragmentScannerImpl
        Returns:
        The element depth.
        Throws:
        java.io.IOException
        org.apache.xerces.xni.XNIException
      • reset

        public void reset​(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
                   throws org.apache.xerces.xni.parser.XMLConfigurationException
        Description copied from class: XMLDocumentScannerImpl
        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 XMLDocumentScannerImpl
        Parameters:
        componentManager - The component manager.
        Throws:
        org.apache.xerces.xni.parser.XMLConfigurationException