Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
org.xml.sax.helpers

Class XMLReaderAdapter

java.lang.Object
|
+--org.xml.sax.helpers.XMLReaderAdapter

All Implemented Interfaces:

Parser, ContentHandler


public class XMLReaderAdapter

extends Object

implements Parser, ContentHandler

Adapt a SAX2 XMLReader as a SAX1 Parser.
This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY. See http://www.saxproject.org for further information.

This class wraps a SAX2 org.xml.sax.XMLReader XMLReader and makes it act as a SAX1 org.xml.sax.Parser Parser. The XMLReader must support a true value for the http://xml.org/sax/features/namespace-prefixes property or parsing will fail with a org.xml.sax.SAXException SAXException; if the XMLReader supports a false value for the http://xml.org/sax/features/namespaces property, that will also be used to improve efficiency.

Since:Author:See Also:

Constructor Summary

XMLReaderAdapter()

Create a new adapter.
XMLReaderAdapter(org.xml.sax.XMLReader xmlReader)

Create a new adapter.

Method Summary

voidcharacters(char[] ch, int start, int length)

Adapt a SAX2 characters event.
voidendDocument()

End document event.
voidendElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)

Adapt a SAX2 end element event.
voidendPrefixMapping(java.lang.String prefix)

Adapt a SAX2 end prefix mapping event.
voidignorableWhitespace(char[] ch, int start, int length)

Adapt a SAX2 ignorable whitespace event.
voidparse(java.lang.String systemId)

Parse the document.
voidparse(org.xml.sax.InputSource input)

Parse the document.
voidprocessingInstruction(java.lang.String target, java.lang.String data)

Adapt a SAX2 processing instruction event.
voidsetDTDHandler(org.xml.sax.DTDHandler handler)

Register the DTD event handler.
voidsetDocumentHandler(org.xml.sax.DocumentHandler handler)

Register the SAX1 document event handler.
voidsetDocumentLocator(org.xml.sax.Locator locator)

Set a document locator.
voidsetEntityResolver(org.xml.sax.EntityResolver resolver)

Register the entity resolver.
voidsetErrorHandler(org.xml.sax.ErrorHandler handler)

Register the error event handler.
voidsetLocale(java.util.Locale locale)

Set the locale for error reporting.
voidskippedEntity(java.lang.String name)

Adapt a SAX2 skipped entity event.
voidstartDocument()

Start document event.
voidstartElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)

Adapt a SAX2 start element event.
voidstartPrefixMapping(java.lang.String prefix, java.lang.String uri)

Adapt a SAX2 start prefix mapping event.

Constructor Details

XMLReaderAdapter

public XMLReaderAdapter()

Create a new adapter.

Use the "org.xml.sax.driver" property to locate the SAX2 driver to embed.

Throws:


XMLReaderAdapter

public XMLReaderAdapter(org.xml.sax.XMLReader xmlReader)

Create a new adapter.

Create a new adapter, wrapped around a SAX2 XMLReader. The adapter will make the XMLReader act like a SAX1 Parser.

Parameters:

Throws:


Method Details

characters

public void characters(char[] ch, int start, int length)

Adapt a SAX2 characters event.

Parameters:

Throws:

See Also:


endDocument

public void endDocument()

End document event.

Throws:

See Also:


endElement

public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)

Adapt a SAX2 end element event.

Parameters:

Throws:

See Also:


endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)

Adapt a SAX2 end prefix mapping event.

Parameters:

See Also:


ignorableWhitespace

public void ignorableWhitespace(char[] ch, int start, int length)

Adapt a SAX2 ignorable whitespace event.

Parameters:

Throws:

See Also:


parse

public void parse(java.lang.String systemId)

Parse the document.

This method will throw an exception if the embedded XMLReader does not support the http://xml.org/sax/features/namespace-prefixes property.

Parameters:

Throws:

See Also:


parse

public void parse(org.xml.sax.InputSource input)

Parse the document.

This method will throw an exception if the embedded XMLReader does not support the http://xml.org/sax/features/namespace-prefixes property.

Parameters:

Throws:

See Also:


processingInstruction

public void processingInstruction(java.lang.String target, java.lang.String data)

Adapt a SAX2 processing instruction event.

Parameters:

Throws:

See Also:


setDTDHandler

public void setDTDHandler(org.xml.sax.DTDHandler handler)

Register the DTD event handler.

Parameters:

See Also:


setDocumentHandler

public void setDocumentHandler(org.xml.sax.DocumentHandler handler)

Register the SAX1 document event handler.

Note that the SAX1 document handler has no Namespace support.

Parameters:

See Also:


setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)

Set a document locator.

Parameters:

See Also:


setEntityResolver

public void setEntityResolver(org.xml.sax.EntityResolver resolver)

Register the entity resolver.

Parameters:

See Also:


setErrorHandler

public void setErrorHandler(org.xml.sax.ErrorHandler handler)

Register the error event handler.

Parameters:

See Also:


setLocale

public void setLocale(java.util.Locale locale)

Set the locale for error reporting.

This is not supported in SAX2, and will always throw an exception.

Parameters:

Throws:

See Also:


skippedEntity

public void skippedEntity(java.lang.String name)

Adapt a SAX2 skipped entity event.

Parameters:

Throws:

See Also:


startDocument

public void startDocument()

Start document event.

Throws:

See Also:


startElement

public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)

Adapt a SAX2 start element event.

Parameters:

Throws:

See Also:


startPrefixMapping

public void startPrefixMapping(java.lang.String prefix, java.lang.String uri)

Adapt a SAX2 start prefix mapping event.

Parameters:

See Also: