xml

## Class XMLScanner

- java.lang.Object
- - xml.XMLScanner

- Direct Known Subclasses:
    SiGMLStreamTransmitter

      public class XMLScanner
      extends java.lang.Object

  An `XMLScanner` provides a convenient packaging of a JAXP-based SAX 2 XML Parser.

  Each of the methods `scanXML(InputSource,DefaultHandler)` and `scanXMLText(String,DefaultHandler)` takes some form of XML source and a `DefaultHandler` (or sub-class) instance as arguments, and invokes the parser on that XML source -- resulting in the delivery of a sequence of SAX events to the handler.

  [This version spent some time in the package xml.newsax, while an older version was here in pagckage xml. This version differs from the older one in that it responds to the various SAX and IO exceptions by throwing an instance of an internally defined ScanException class rather than by simply aborting the JVM.]

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `XMLScanner.ScanException` All-purpose scanner exception class.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `SAX_NAMESPACES` SAX namespaces feature name.
    `static java.lang.String` | `SAX_NS_PREFIXES` SAX namespace prefixes feature name.
    `static java.lang.String` | `SAX_STRING_INTERN` SAX string interning feature name.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XMLScanner(java.lang.String intag)` Constructs a new validating scanner with the given idenfification tag.
    `XMLScanner(java.lang.String intag, boolean validate)` Constructs a new scanner with the given idenfification tag, performing XML validataion or not, as specified.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `getSPXLineColText(org.xml.sax.SAXParseException spx)` Returns line and column number text for the given SAX parse exception.
    `static java.lang.String` | `getSPXLocationText(org.xml.sax.SAXParseException spx)` Returns a full location text, including System Id if available, for the given SAX parse exception.
    `void` | `scanXML(org.xml.sax.InputSource insrc, org.xml.sax.helpers.DefaultHandler hndlr)` Parses the given source XML document, feeding SAX parse events to the given handler.
    `void` | `scanXML(java.lang.String inuri, org.xml.sax.helpers.DefaultHandler hndlr)` Parses the source XML document with the given URI, feeding SAX parse events to the given handler.
    `void` | `scanXMLText(java.lang.String txt, org.xml.sax.helpers.DefaultHandler hndlr)` Parses the given XML document text, feeding SAX parse events to the given handler.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SAX_NAMESPACES

          public static final java.lang.String SAX_NAMESPACES

      SAX namespaces feature name.
      See Also:
        Constant Field Values

    - #### SAX_NS_PREFIXES

          public static final java.lang.String SAX_NS_PREFIXES

      SAX namespace prefixes feature name.
      See Also:
        Constant Field Values

    - #### SAX_STRING_INTERN

          public static final java.lang.String SAX_STRING_INTERN

      SAX string interning feature name.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### XMLScanner

          public XMLScanner(java.lang.String intag)
                     throws XMLScanner.ScanException

      Constructs a new validating scanner with the given idenfification tag.
      Throws:
        `XMLScanner.ScanException`

    - #### XMLScanner

          public XMLScanner(java.lang.String intag,
                            boolean validate)
                     throws XMLScanner.ScanException

      Constructs a new scanner with the given idenfification tag, performing XML validataion or not, as specified.
      Throws:
        `XMLScanner.ScanException`

  - ### Method Detail

    - #### scanXML

          public void scanXML(org.xml.sax.InputSource insrc,
                              org.xml.sax.helpers.DefaultHandler hndlr)
                       throws XMLScanner.ScanException

      Parses the given source XML document, feeding SAX parse events to the given handler.
      Throws:
        `XMLScanner.ScanException`

    - #### scanXML

          public void scanXML(java.lang.String inuri,
                              org.xml.sax.helpers.DefaultHandler hndlr)
                       throws XMLScanner.ScanException

      Parses the source XML document with the given URI, feeding SAX parse events to the given handler.
      Throws:
        `XMLScanner.ScanException`

    - #### scanXMLText

          public void scanXMLText(java.lang.String txt,
                                  org.xml.sax.helpers.DefaultHandler hndlr)
                           throws XMLScanner.ScanException

      Parses the given XML document text, feeding SAX parse events to the given handler.
      Throws:
        `XMLScanner.ScanException`

    - #### getSPXLocationText

          public static java.lang.String getSPXLocationText(org.xml.sax.SAXParseException spx)

      Returns a full location text, including System Id if available, for the given SAX parse exception.

    - #### getSPXLineColText

          public static java.lang.String getSPXLineColText(org.xml.sax.SAXParseException spx)

      Returns line and column number text for the given SAX parse exception.