Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle® Application Server XML Java API Reference 10g Release 2 (10.1.2) Part no. B12024-03 September 2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.xml.parser.v2
Class SAXParser

    java.lang.Object
      |
      +--oracle.xml.parser.v2.XMLParser
            |
            +--oracle.xml.parser.v2.SAXParser

All Implemented Interfaces:
  Parser, XMLReader

public class SAXParser
extends XMLParser
implements XMLReader, Parser

This class implements an eXtensible Markup Language (XML) 1.0 SAX parser according to the World Wide Web Consortium (W3C) recommendation. Applications can register a SAX handler to receive notification of various parser events.

XMLReader is the interface that an XML parser's SAX2 driver must implement. This interface allows an application to set and query features and properties in the parser, to register event handlers for document processing, and to initiate a document parse.

All SAX interfaces are assumed to be synchronous: the parse methods must not return until parsing is complete, and readers must wait for an event-handler callback to return before reporting the next event.

This interface replaces the (now deprecated) SAX 1.0 Parser interface. The XMLReader interface contains two important enhancements over the old Parser interface:

1. it adds a standard way to query and set features and properties; and
2. it adds Namespace support, which is required for many higher-level XML standards.

Field Summary
`static java.lang.String` | `REPORT_CHARS_CHUNKS` Report characters in chunks.

Fields inherited from class oracle.xml.parser.v2.XMLParser
`attributes, BASE_URL, DTD_OBJECT, EXPAND_ENTITYREF, PARSER, PARSER_CDATA, PARSER_DTD, SCHEMA_LANGUAGE, SCHEMA_OBJECT, SCHEMA_SOURCE, STANDALONE, USE_DTD_ONLY_FOR_VALIDATION`

Constructor Summary
`SAXParser()` Creates a new parser object.

Method Summary
`ContentHandler` | `getContentHandler()` Return the current content handler.
`DTDHandler` | `getDTDHandler()` Return the current DTD handler.
`boolean` | `getFeature(java.lang.String name)` Look up the value of a feature.
`java.lang.Object` | `getProperty(java.lang.String name)` Look up the value of a property.
`void` | `setContentHandler(ContentHandler handler)` Allow an application to register a content event handler.
`void` | `setDocumentHandler(DocumentHandler handler)` Deprecated. as of SAX2.0 - Replaced by setContentHandler
`void` | `setDTDHandler(DTDHandler handler)` Allow an application to register a DTD event handler.
`void` | `setFeature(java.lang.String name, boolean value)` Set the state of a feature.
`void` | `setProperty(java.lang.String name, java.lang.Object value)` Set the value of a property.

Methods inherited from class oracle.xml.parser.v2.XMLParser
`getAttribute, getBaseURL, getEntityResolver, getErrorHandler, getReleaseVersion, getValidationMode, getValidationModeValue, getXMLProperty, isXMLPropertyReadOnly, isXMLPropertySupported, parse, parse, parse, parse, parse, reset, setAttribute, setBaseURL, setDoctype, setEntityResolver, setErrorHandler, setLocale, setPreserveWhitespace, setSchemaValidationMode, setValidationMode, setValidationMode, setXMLProperty, setXMLSchema`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.xml.sax.XMLReader
`getEntityResolver, getErrorHandler, parse, parse, setEntityResolver, setErrorHandler`

Methods inherited from interface org.xml.sax.Parser
`parse, parse, setEntityResolver, setErrorHandler, setLocale`

Field Detail

### REPORT_CHARS_CHUNKS

    public static final java.lang.String REPORT_CHARS_CHUNKS

  Report characters in chunks. If this property is set to TRUE the parser reports characters in multiple call, if the data is large.
  See Also:
    Constant Field Values

Constructor Detail

### SAXParser

    public SAXParser()

  Creates a new parser object.

Method Detail

### setDocumentHandler

    public void setDocumentHandler(DocumentHandler handler)

  Deprecated. as of SAX2.0 - Replaced by setContentHandler
  SAX applications can use this to register a new document event handler.
  Specified by:
    `setDocumentHandler` in interface `Parser`
  Parameters:
    `handler` - `DocumentHandler` being registered
  See Also:
    `Parser.setDocumentHandler(org.xml.sax.DocumentHandler)`, `DocumentHandler`

### getFeature

    public boolean getFeature(java.lang.String name)
                       throws SAXNotRecognizedException,
    SAXNotSupportedException

  Look up the value of a feature.

  The feature name is any fully-qualified URI. It is possible for an XMLReader to recognize a feature name but to be unable to return its value; this is especially true in the case of an adapter for a SAX1 Parser, which has no way of knowing whether the underlying parser is performing validation or expanding external entities.

  All XMLReaders are required to recognize the http://xml.org/sax/features/namespaces and the http://xml.org/sax/features/namespace-prefixes feature names.

  Some feature values may be available only in specific contexts, such as before, during, or after a parse.

  Typical usage is something like this:

       XMLReader r = new MySAXDriver();

                               // try to activate validation
       try {
         r.setFeature("http://xml.org/sax/features/validation", true);
       } catch (SAXException e) {
         System.err.println("Cannot activate validation.");
       }

                               // register event handlers
       r.setContentHandler(new MyContentHandler());
       r.setErrorHandler(new MyErrorHandler());

                               // parse the first document
       try {
         r.parse("http://www.foo.com/mydoc.xml");
       } catch (IOException e) {
         System.err.println("I/O exception reading XML document");
       } catch (SAXException e) {
         System.err.println("XML exception reading document.");
       }

  The feature "http://xml.org/sax/features/validation" due to its binary input value only controls DTD validation. The value true sets DTD validation to TRUE. This feature cannot be used to control XML Schema based validation

  Implementors are free (and encouraged) to invent their own features, using names built on their own URIs.

  Specified by:
    `getFeature` in interface `XMLReader`
  Parameters:
    `name` - The feature name, which is a fully-qualified URI.
  Returns:
    The current state of the feature (true or false).
  Throws:
    `SAXNotRecognizedException` - When the XMLReader does not recognize the feature name.
    `SAXNotSupportedException` - When the XMLReader recognizes the feature name but cannot determine its value at this time.
  See Also:
    `setFeature(java.lang.String, boolean)`

### setFeature

    public void setFeature(java.lang.String name,
                           boolean value)
                    throws SAXNotRecognizedException,
    SAXNotSupportedException

  Set the state of a feature.

  The feature name is any fully-qualified URI. It is possible for an XMLReader to recognize a feature name but to be unable to set its value; this is especially true in the case of an adapter for a SAX1 `Parser`, which has no way of affecting whether the underlying parser is validating, for example.

  All XMLReaders are required to support setting http://xml.org/sax/features/namespaces to true and http://xml.org/sax/features/namespace-prefixes to false.

  Some feature values may be immutable or mutable only in specific contexts, such as before, during, or after a parse.

  The feature "http://xml.org/sax/features/validation" due to its binary input value only controls DTD validation. The value true sets DTD validation to TRUE. This feature cannot be used to control XML Schema based validation

  Specified by:
    `setFeature` in interface `XMLReader`
  Parameters:
    `name` - The feature name, which is a fully-qualified URI.
    `value` - The requested value of the feature (true or false).
  Throws:
    `SAXNotRecognizedException` - When the XMLReader does not recognize the feature name.
    `SAXNotSupportedException` - When the XMLReader recognizes the feature name but cannot set the requested value.
  See Also:
    `getFeature(java.lang.String)`

### getProperty

    public java.lang.Object getProperty(java.lang.String name)
                                 throws SAXNotRecognizedException,
    SAXNotSupportedException

  Look up the value of a property.

  The property name is any fully-qualified URI. It is possible for an XMLReader to recognize a property name but to be unable to return its state; this is especially true in the case of an adapter for a SAX1 `Parser`.

  XMLReaders are not required to recognize any specific property names, though an initial core set is documented for SAX2.

  Some property values may be available only in specific contexts, such as before, during, or after a parse.

  Implementors are free (and encouraged) to invent their own properties, using names built on their own URIs.

  Specified by:
    `getProperty` in interface `XMLReader`
  Parameters:
    `name` - The property name, which is a fully-qualified URI.
  Returns:
    The current value of the property.
  Throws:
    `SAXNotRecognizedException` - When the XMLReader does not recognize the property name.
    `SAXNotSupportedException` - When the XMLReader recognizes the property name but cannot determine its value at this time.
  See Also:
    `setProperty(java.lang.String, java.lang.Object)`

### setProperty

    public void setProperty(java.lang.String name,
                            java.lang.Object value)
                     throws SAXNotRecognizedException,
    SAXNotSupportedException

  Set the value of a property.

  The property name is any fully-qualified URI. It is possible for an XMLReader to recognize a property name but to be unable to set its value; this is especially true in the case of an adapter for a SAX1 `Parser`.

  XMLReaders are not required to recognize setting any specific property names, though a core set is provided with SAX2.

  Some property values may be immutable or mutable only in specific contexts, such as before, during, or after a parse.

  This method is also the standard mechanism for setting extended handlers.

  Specified by:
    `setProperty` in interface `XMLReader`
  Parameters:
    `name` - The property name, which is a fully-qualified URI.
    `value` - The requested value for the property.
  Throws:
    `SAXNotRecognizedException` - When the XMLReader does not recognize the property name.
    `SAXNotSupportedException` - When the XMLReader recognizes the property name but cannot set the requested value.

### setDTDHandler

    public void setDTDHandler(DTDHandler handler)

  Allow an application to register a DTD event handler.

  If the application does not register a DTD handler, all DTD events reported by the SAX parser will be silently ignored.

  Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.

  Specified by:
    `setDTDHandler` in interface `XMLReader`
  Parameters:
    `handler` - The DTD handler.
  Throws:
    `java.lang.NullPointerException` - If the handler argument is null.
  See Also:
    `getDTDHandler()`

### getDTDHandler

    public DTDHandler getDTDHandler()

  Return the current DTD handler.
  Specified by:
    `getDTDHandler` in interface `XMLReader`
  Returns:
    The current DTD handler, or null if none has been registered.
  Since:
    SAX 2.0
  See Also:
    `setDTDHandler(org.xml.sax.DTDHandler)`

### setContentHandler

    public void setContentHandler(ContentHandler handler)

  Allow an application to register a content event handler.

  If the application does not register a content handler, all content events reported by the SAX parser will be silently ignored.

  Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.

  Specified by:
    `setContentHandler` in interface `XMLReader`
  Parameters:
    `handler` - The content handler.
  Throws:
    `java.lang.NullPointerException` - If the handler argument is null.
  Since:
    SAX 2.0
  See Also:
    `getContentHandler()`

### getContentHandler

    public ContentHandler getContentHandler()

  Return the current content handler.
  Specified by:
    `getContentHandler` in interface `XMLReader`
  Returns:
    The current content handler, or null if none has been registered.
  Since:
    SAX 2.0
  See Also:
    `setContentHandler(org.xml.sax.ContentHandler)`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle® Application Server XML Java API Reference 10g Release 2 (10.1.2) Part no. B12024-03 September 2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003, 2004, Oracle. All rights reserved.