Top Description Inners Fields Constructors Methods
org.dom4j.io

public Class SAXReader

extends Object
Class Inheritance
Known Direct Subclasses
org.dom4j.io.SAXModifyReader
Imports
java.io.File, .FileInputStream, .FileNotFoundException, .InputStream, .Reader, .Serializable, java.net.URL, org.dom4j.Document, .DocumentException, .DocumentFactory, .ElementHandler, org.xml.sax.EntityResolver, .ErrorHandler, .InputSource, .SAXException, .SAXParseException, .XMLFilter, .XMLReader, org.xml.sax.helpers.DefaultHandler, .XMLReaderFactory, javax.xml.parsers.SAXParserFactory

SAXReader creates a DOM4J tree from SAX parsing events.

The actual SAX parser that is used by this class is configurable so you can use your favourite SAX parser if you wish. DOM4J comes configured with its own SAX parser so you do not need to worry about configuring the SAX parser.

To explicitly configure the SAX parser that is used via Java code you can use a constructor or use the setXMLReader(XMLReader)or setXMLReaderClassName(String) methods.

If the parser is not specified explicitly then the standard SAX policy of using the org.xml.sax.driver system property is used to determine the implementation class of XMLReader.

If the org.xml.sax.driver system property is not defined then JAXP is used via reflection (so that DOM4J is not explicitly dependent on the JAXP classes) to load the JAXP configured SAXParser. If there is any error creating a JAXP SAXParser an informational message is output and then the default (Aelfred) SAX parser is used instead.

If you are trying to use JAXP to explicitly set your SAX parser and are experiencing problems, you can turn on verbose error reporting by defining the system property org.dom4j.verbose to be "true" which will output a more detailed description of why JAXP could not find a SAX parser

For more information on JAXP please go to Sun's Java & XML site

Author
James Strachan
Version
$Revision: 1.58 $

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class

Field Summary

Modifier and TypeField and Description
private DispatchHandler
dispatchHandler

DispatchHandler to call when each Element is encountered

private String
encoding

Encoding of InputSource - null means system default encoding

private EntityResolver
entityResolver

The entity resolver

private ErrorHandler
errorHandler

ErrorHandler class to use

private DocumentFactory
factory

DocumentFactory used to create new document objects

private boolean
ignoreComments

Should we ignore comments

private boolean
includeExternalDTDDeclarations

Should external DTD declarations be expanded into a List in the DTD

private boolean
includeInternalDTDDeclarations

Should internal DTD declarations be expanded into a List in the DTD

private boolean
mergeAdjacentText

Whether adjacent text nodes should be merged

private static final String
private static final String
private static final String
private static final String
private boolean
stringInternEnabled

Should element & attribute names and namespace URIs be interned?

private boolean
stripWhitespaceText

Holds value of property stripWhitespaceText.

private boolean
validating

Whether validation should occur

private XMLFilter
xmlFilter

The SAX filter used to filter SAX events

private XMLReader
xmlReader

XMLReader used to parse the SAX events

Constructor Summary

AccessConstructor and Description
public
SAXReader()

This method internally calls SAXParserFactory.newInstance().newSAXParser().getXMLReader() or XMLReaderFactory#createXMLReader().

public
SAXReader(boolean validating)

This method internally calls SAXParserFactory.newInstance().newSAXParser().getXMLReader() or XMLReaderFactory#createXMLReader().

public
SAXReader(DocumentFactory factory)

This method internally calls SAXParserFactory.newInstance().newSAXParser().getXMLReader() or XMLReaderFactory#createXMLReader().

public
SAXReader(DocumentFactory factory, boolean validating)

This method internally calls SAXParserFactory.newInstance().newSAXParser().getXMLReader() or XMLReaderFactory#createXMLReader().

public
SAXReader(XMLReader xmlReader)

public
SAXReader(XMLReader xmlReader, boolean validating)

public
SAXReader(String xmlReaderClassName)

public
SAXReader(String xmlReaderClassName, boolean validating)

Method Summary

Modifier and TypeMethod and Description
public void
addHandler(String
is the path to be handled
path
,
ElementHandler
is the ElementHandler to be called by the event based processor.
handler
)

Adds the ElementHandler to be called when the specified path is encounted.

protected void
configureReader(XMLReader
DOCUMENT ME!
reader
,
DefaultHandler
DOCUMENT ME!
handler
)

Configures the XMLReader before use

protected SAXContentHandler

Returns:

DOCUMENT ME!
createContentHandler
(XMLReader
DOCUMENT ME!
reader
)

Factory Method to allow user derived SAXContentHandler objects to be used

public static SAXReader
protected EntityResolver
protected XMLReader

Returns:

DOCUMENT ME!
createXMLReader
()

Factory Method to allow alternate methods of creating and configuring XMLReader objects

protected DispatchHandler
public DocumentFactory

Returns:

the DocumentFactory used to create document objects
getDocumentFactory
()

DOCUMENT ME!

public String

Returns:

encoding used for InputSource
getEncoding
()

Returns encoding used for InputSource (null means system default encoding)

public EntityResolver

Returns:

DOCUMENT ME!
getEntityResolver
()

Returns the current entity resolver used to resolve entities

public ErrorHandler

Returns:

the ErrorHandler used by SAX
getErrorHandler
()

DOCUMENT ME!

public XMLFilter

Returns:

the SAX filter being used or null if no SAX filter is installed
getXMLFilter
()

Returns the SAX filter being used to filter SAX events.

public XMLReader

Returns:

the XMLReader used to parse SAX events
getXMLReader
()

DOCUMENT ME!

protected XMLReader

Returns:

the new XMLFilter if applicable or the original XMLReader if no filter is being used.
installXMLFilter
(XMLReader
DOCUMENT ME!
reader
)

Installs any XMLFilter objects required to allow the SAX event stream to be filtered and preprocessed before it gets to dom4j.

public boolean

Returns:

boolean
isIgnoreComments
()

Returns whether we should ignore comments or not.

public boolean

Returns:

whether external DTD declarations should be expanded into the DocumentType object or not.
isIncludeExternalDTDDeclarations
()

DOCUMENT ME!

public boolean

Returns:

whether internal DTD declarations should be expanded into the DocumentType object or not.
isIncludeInternalDTDDeclarations
()

DOCUMENT ME!

public boolean

Returns:

Value of property mergeAdjacentText.
isMergeAdjacentText
()

Returns whether adjacent text nodes should be merged together.

public boolean

Returns:

DOCUMENT ME!
isStringInternEnabled
()

Sets whether String interning is enabled or disabled for element & attribute names and namespace URIs.

public boolean

Returns:

Value of property stripWhitespaceText.
isStripWhitespaceText
()

Sets whether whitespace between element start and end tags should be ignored

public boolean

Returns:

the validation mode, true if validating will be done otherwise false.
isValidating
()

DOCUMENT ME!

public Document

Returns:

the newly created Document instance
read
(File
is the File to read from.
file
)

Reads a Document from the given File

public Document

Returns:

the newly created Document instance
read
(URL
URL to read from.
url
)

Reads a Document from the given URL using SAX

public Document

Returns:

the newly created Document instance
read
(String
is a URL for a document or a file name.
systemId
)

Reads a Document from the given URL or filename using SAX.

public Document

Returns:

the newly created Document instance
read
(InputStream
InputStream to read from.
in
)

Reads a Document from the given stream using SAX

public Document

Returns:

the newly created Document instance
read
(Reader
is the reader for the input
reader
)

Reads a Document from the given Reader using SAX

public Document

Returns:

the newly created Document instance
read
(InputStream
InputStream to read from.
in
,
String
is the URI for the input
systemId
)

Reads a Document from the given stream using SAX

public Document

Returns:

the newly created Document instance
read
(Reader
is the reader for the input
reader
,
String
is the URI for the input
systemId
)

Reads a Document from the given Reader using SAX

public Document

Returns:

the newly created Document instance
read
(InputSource
InputSource to read from.
in
)

Reads a Document from the given InputSource using SAX

public void
removeHandler(String
is the path to remove the ElementHandler for.
path
)

Removes the ElementHandler from the event based processor, for the specified path.

public void
resetHandlers()

This method clears out all the existing handlers and default handler setting things back as if no handler existed.

public void
setDefaultHandler(ElementHandler
is the ElementHandler to be called by the event based processor.
handler
)

When multiple ElementHandler instances have been registered, this will set a default ElementHandler to be called for any path which does NOT have a handler registered.

protected void
public void
setDocumentFactory(DocumentFactory
DocumentFactory used to create DOM4J objects
documentFactory
)

This sets the DocumentFactory used to create new documents.

public void
setEncoding(String
is encoding used for InputSource
encoding
)

Sets encoding used for InputSource (null means system default encoding)

public void
setEntityResolver(EntityResolver
DOCUMENT ME!
entityResolver
)

Sets the entity resolver used to resolve entities.

public void
setErrorHandler(ErrorHandler
is the ErrorHandler used by SAX
errorHandler
)

Sets the ErrorHandler used by the SAX XMLReader.

public void
setFeature(String
is the SAX feature name
name
,
boolean
is the value of the SAX feature
value
)

Sets a SAX feature on the underlying SAX parser.

public void
setIgnoreComments(boolean
whether we should ignore comments or not.
ignoreComments
)

Sets whether we should ignore comments or not.

public void
setIncludeExternalDTDDeclarations(boolean
whether or not DTD declarations should be expanded and included into the DocumentType object.
include
)

Sets whether DTD external declarations should be expanded into the DocumentType object or not.

public void
setIncludeInternalDTDDeclarations(boolean
whether or not DTD declarations should be expanded and included into the DocumentType object.
include
)

Sets whether internal DTD declarations should be expanded into the DocumentType object or not.

public void
setMergeAdjacentText(boolean
New value of property mergeAdjacentText.
mergeAdjacentText
)

Sets whether or not adjacent text nodes should be merged together when parsing.

public void
setProperty(String
is the SAX property name
name
,
Object
is the value of the SAX property
value
)

Allows a SAX property to be set on the underlying SAX parser.

public void
setStringInternEnabled(boolean
DOCUMENT ME!
stringInternEnabled
)

Sets whether String interning is enabled or disabled for element & attribute names and namespace URIs

public void
setStripWhitespaceText(boolean
New value of property stripWhitespaceText.
stripWhitespaceText
)

Sets whether whitespace between element start and end tags should be ignored.

public void
setValidation(boolean
indicates whether or not validation should occur.
validation
)

Sets the validation mode.

public void
setXMLFilter(XMLFilter
is the SAX filter to use or null to disable filtering
filter
)

Sets the SAX filter to be used when filtering SAX events

public void
setXMLReader(XMLReader
is the XMLReader to parse SAX events
reader
)

Sets the XMLReader used to parse SAX events

public void
setXMLReaderClassName(String
is the class name of the XMLReader to parse SAX events
xmlReaderClassName
)

Sets the class name of the XMLReader to be used to parse SAX events.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dispatchHandlerback to summary
private DispatchHandler dispatchHandler

DispatchHandler to call when each Element is encountered

encodingback to summary
private String encoding

Encoding of InputSource - null means system default encoding

entityResolverback to summary
private EntityResolver entityResolver

The entity resolver

errorHandlerback to summary
private ErrorHandler errorHandler

ErrorHandler class to use

factoryback to summary
private DocumentFactory factory

DocumentFactory used to create new document objects

ignoreCommentsback to summary
private boolean ignoreComments

Should we ignore comments

includeExternalDTDDeclarationsback to summary
private boolean includeExternalDTDDeclarations

Should external DTD declarations be expanded into a List in the DTD

includeInternalDTDDeclarationsback to summary
private boolean includeInternalDTDDeclarations

Should internal DTD declarations be expanded into a List in the DTD

mergeAdjacentTextback to summary
private boolean mergeAdjacentText

Whether adjacent text nodes should be merged

SAX_DECL_HANDLERback to summary
private static final String SAX_DECL_HANDLER
SAX_LEXICAL_HANDLERback to summary
private static final String SAX_LEXICAL_HANDLER
SAX_LEXICALHANDLERback to summary
private static final String SAX_LEXICALHANDLER
SAX_STRING_INTERNINGback to summary
private static final String SAX_STRING_INTERNING
stringInternEnabledback to summary
private boolean stringInternEnabled

Should element & attribute names and namespace URIs be interned?

stripWhitespaceTextback to summary
private boolean stripWhitespaceText

Holds value of property stripWhitespaceText.

validatingback to summary
private boolean validating

Whether validation should occur

xmlFilterback to summary
private XMLFilter xmlFilter

The SAX filter used to filter SAX events

Since
2.1.2
xmlReaderback to summary
private XMLReader xmlReader

XMLReader used to parse the SAX events

Constructor Detail

SAXReaderback to summary
public SAXReader()

This method internally calls SAXParserFactory.newInstance().newSAXParser().getXMLReader() or XMLReaderFactory#createXMLReader(). Be sure to configure returned reader if the default configuration does not suit you. Consider setting the following properties:

reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
reader.setFeature("http://xml.org/sax/features/external-general-entities", false);
reader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
SAXReaderback to summary
public SAXReader(boolean validating)

This method internally calls SAXParserFactory.newInstance().newSAXParser().getXMLReader() or XMLReaderFactory#createXMLReader(). Be sure to configure returned reader if the default configuration does not suit you. Consider setting the following properties:

reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
reader.setFeature("http://xml.org/sax/features/external-general-entities", false);
reader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
SAXReaderback to summary
public SAXReader(DocumentFactory factory)

This method internally calls SAXParserFactory.newInstance().newSAXParser().getXMLReader() or XMLReaderFactory#createXMLReader(). Be sure to configure returned reader if the default configuration does not suit you. Consider setting the following properties:

reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
reader.setFeature("http://xml.org/sax/features/external-general-entities", false);
reader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
SAXReaderback to summary
public SAXReader(DocumentFactory factory, boolean validating)

This method internally calls SAXParserFactory.newInstance().newSAXParser().getXMLReader() or XMLReaderFactory#createXMLReader(). Be sure to configure returned reader if the default configuration does not suit you. Consider setting the following properties:

reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
reader.setFeature("http://xml.org/sax/features/external-general-entities", false);
reader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
SAXReaderback to summary
public SAXReader(XMLReader xmlReader)
SAXReaderback to summary
public SAXReader(XMLReader xmlReader, boolean validating)
SAXReaderback to summary
public SAXReader(String xmlReaderClassName) throws SAXException
SAXReaderback to summary
public SAXReader(String xmlReaderClassName, boolean validating) throws SAXException

Method Detail

addHandlerback to summary
public void addHandler(String path, ElementHandler handler)

Adds the ElementHandler to be called when the specified path is encounted.

Parameters
path:String

is the path to be handled

handler:ElementHandler

is the ElementHandler to be called by the event based processor.

configureReaderback to summary
protected void configureReader(XMLReader reader, DefaultHandler handler) throws DocumentException

Configures the XMLReader before use

Parameters
reader:XMLReader

DOCUMENT ME!

handler:DefaultHandler

DOCUMENT ME!

Exceptions
DocumentException:
DOCUMENT ME!
createContentHandlerback to summary
protected SAXContentHandler createContentHandler(XMLReader reader)

Factory Method to allow user derived SAXContentHandler objects to be used

Parameters
reader:XMLReader

DOCUMENT ME!

Returns:SAXContentHandler

DOCUMENT ME!

createDefaultback to summary
public static SAXReader createDefault()
createDefaultEntityResolverback to summary
protected EntityResolver createDefaultEntityResolver(String systemId)
createXMLReaderback to summary
protected XMLReader createXMLReader() throws SAXException

Factory Method to allow alternate methods of creating and configuring XMLReader objects

Returns:XMLReader

DOCUMENT ME!

Exceptions
SAXException:
DOCUMENT ME!
getDispatchHandlerback to summary
protected DispatchHandler getDispatchHandler()
getDocumentFactoryback to summary
public DocumentFactory getDocumentFactory()

DOCUMENT ME!

Returns:DocumentFactory

the DocumentFactory used to create document objects

getEncodingback to summary
public String getEncoding()

Returns encoding used for InputSource (null means system default encoding)

Returns:String

encoding used for InputSource

getEntityResolverback to summary
public EntityResolver getEntityResolver()

Returns the current entity resolver used to resolve entities

Returns:EntityResolver

DOCUMENT ME!

getErrorHandlerback to summary
public ErrorHandler getErrorHandler()

DOCUMENT ME!

Returns:ErrorHandler

the ErrorHandler used by SAX

getXMLFilterback to summary
public XMLFilter getXMLFilter()

Returns the SAX filter being used to filter SAX events.

Returns:XMLFilter

the SAX filter being used or null if no SAX filter is installed

getXMLReaderback to summary
public XMLReader getXMLReader() throws SAXException

DOCUMENT ME!

Returns:XMLReader

the XMLReader used to parse SAX events

Exceptions
SAXException:
DOCUMENT ME!
installXMLFilterback to summary
protected XMLReader installXMLFilter(XMLReader reader)

Installs any XMLFilter objects required to allow the SAX event stream to be filtered and preprocessed before it gets to dom4j.

Parameters
reader:XMLReader

DOCUMENT ME!

Returns:XMLReader

the new XMLFilter if applicable or the original XMLReader if no filter is being used.

isIgnoreCommentsback to summary
public boolean isIgnoreComments()

Returns whether we should ignore comments or not.

Returns:boolean

boolean

isIncludeExternalDTDDeclarationsback to summary
public boolean isIncludeExternalDTDDeclarations()

DOCUMENT ME!

Returns:boolean

whether external DTD declarations should be expanded into the DocumentType object or not.

isIncludeInternalDTDDeclarationsback to summary
public boolean isIncludeInternalDTDDeclarations()

DOCUMENT ME!

Returns:boolean

whether internal DTD declarations should be expanded into the DocumentType object or not.

isMergeAdjacentTextback to summary
public boolean isMergeAdjacentText()

Returns whether adjacent text nodes should be merged together.

Returns:boolean

Value of property mergeAdjacentText.

isStringInternEnabledback to summary
public boolean isStringInternEnabled()

Sets whether String interning is enabled or disabled for element & attribute names and namespace URIs. This proprety is enabled by default.

Returns:boolean

DOCUMENT ME!

isStripWhitespaceTextback to summary
public boolean isStripWhitespaceText()

Sets whether whitespace between element start and end tags should be ignored

Returns:boolean

Value of property stripWhitespaceText.

isValidatingback to summary
public boolean isValidating()

DOCUMENT ME!

Returns:boolean

the validation mode, true if validating will be done otherwise false.

readback to summary
public Document read(File file) throws DocumentException

Reads a Document from the given File

Parameters
file:File

is the File to read from.

Returns:Document

the newly created Document instance

Exceptions
DocumentException:
if an error occurs during parsing.
readback to summary
public Document read(URL url) throws DocumentException

Reads a Document from the given URL using SAX

Parameters
url:URL

URL to read from.

Returns:Document

the newly created Document instance

Exceptions
DocumentException:
if an error occurs during parsing.
readback to summary
public Document read(String systemId) throws DocumentException

Reads a Document from the given URL or filename using SAX.

If the systemId contains a ':' character then it is assumed to be a URL otherwise its assumed to be a file name. If you want finer grained control over this mechansim then please explicitly pass in either a URLor a Fileinstance instead of a String to denote the source of the document.

Parameters
systemId:String

is a URL for a document or a file name.

Returns:Document

the newly created Document instance

Exceptions
DocumentException:
if an error occurs during parsing.
readback to summary
public Document read(InputStream in) throws DocumentException

Reads a Document from the given stream using SAX

Parameters
in:InputStream

InputStream to read from.

Returns:Document

the newly created Document instance

Exceptions
DocumentException:
if an error occurs during parsing.
readback to summary
public Document read(Reader reader) throws DocumentException

Reads a Document from the given Reader using SAX

Parameters
reader:Reader

is the reader for the input

Returns:Document

the newly created Document instance

Exceptions
DocumentException:
if an error occurs during parsing.
readback to summary
public Document read(InputStream in, String systemId) throws DocumentException

Reads a Document from the given stream using SAX

Parameters
in:InputStream

InputStream to read from.

systemId:String

is the URI for the input

Returns:Document

the newly created Document instance

Exceptions
DocumentException:
if an error occurs during parsing.
readback to summary
public Document read(Reader reader, String systemId) throws DocumentException

Reads a Document from the given Reader using SAX

Parameters
reader:Reader

is the reader for the input

systemId:String

is the URI for the input

Returns:Document

the newly created Document instance

Exceptions
DocumentException:
if an error occurs during parsing.
readback to summary
public Document read(InputSource in) throws DocumentException

Reads a Document from the given InputSource using SAX

Parameters
in:InputSource

InputSource to read from.

Returns:Document

the newly created Document instance

Exceptions
DocumentException:
if an error occurs during parsing.
removeHandlerback to summary
public void removeHandler(String path)

Removes the ElementHandler from the event based processor, for the specified path.

Parameters
path:String

is the path to remove the ElementHandler for.

resetHandlersback to summary
public void resetHandlers()

This method clears out all the existing handlers and default handler setting things back as if no handler existed. Useful when reusing an object instance.

setDefaultHandlerback to summary
public void setDefaultHandler(ElementHandler handler)

When multiple ElementHandler instances have been registered, this will set a default ElementHandler to be called for any path which does NOT have a handler registered.

Parameters
handler:ElementHandler

is the ElementHandler to be called by the event based processor.

setDispatchHandlerback to summary
protected void setDispatchHandler(DispatchHandler dispatchHandler)
setDocumentFactoryback to summary
public void setDocumentFactory(DocumentFactory documentFactory)

This sets the DocumentFactory used to create new documents. This method allows the building of custom DOM4J tree objects to be implemented easily using a custom derivation of DocumentFactory

Parameters
documentFactory:DocumentFactory

DocumentFactory used to create DOM4J objects

setEncodingback to summary
public void setEncoding(String encoding)

Sets encoding used for InputSource (null means system default encoding)

Parameters
encoding:String

is encoding used for InputSource

setEntityResolverback to summary
public void setEntityResolver(EntityResolver entityResolver)

Sets the entity resolver used to resolve entities.

Parameters
entityResolver:EntityResolver

DOCUMENT ME!

setErrorHandlerback to summary
public void setErrorHandler(ErrorHandler errorHandler)

Sets the ErrorHandler used by the SAX XMLReader.

Parameters
errorHandler:ErrorHandler

is the ErrorHandler used by SAX

setFeatureback to summary
public void setFeature(String name, boolean value) throws SAXException

Sets a SAX feature on the underlying SAX parser. This can be useful to set parser-specific features. Though use this method with caution as it has the possibility of breaking the standard behaviour. An alternative to calling this method is to correctly configure an XMLReader object instance and call the setXMLReader(XMLReader)method

Parameters
name:String

is the SAX feature name

value:boolean

is the value of the SAX feature

Exceptions
SAXException:
if the XMLReader could not be created or the feature could not be changed.
setIgnoreCommentsback to summary
public void setIgnoreComments(boolean ignoreComments)

Sets whether we should ignore comments or not.

Parameters
ignoreComments:boolean

whether we should ignore comments or not.

setIncludeExternalDTDDeclarationsback to summary
public void setIncludeExternalDTDDeclarations(boolean include)

Sets whether DTD external declarations should be expanded into the DocumentType object or not.

Parameters
include:boolean

whether or not DTD declarations should be expanded and included into the DocumentType object.

setIncludeInternalDTDDeclarationsback to summary
public void setIncludeInternalDTDDeclarations(boolean include)

Sets whether internal DTD declarations should be expanded into the DocumentType object or not.

Parameters
include:boolean

whether or not DTD declarations should be expanded and included into the DocumentType object.

setMergeAdjacentTextback to summary
public void setMergeAdjacentText(boolean mergeAdjacentText)

Sets whether or not adjacent text nodes should be merged together when parsing.

Parameters
mergeAdjacentText:boolean

New value of property mergeAdjacentText.

setPropertyback to summary
public void setProperty(String name, Object value) throws SAXException

Allows a SAX property to be set on the underlying SAX parser. This can be useful to set parser-specific properties such as the location of schema or DTD resources. Though use this method with caution as it has the possibility of breaking the standard behaviour. An alternative to calling this method is to correctly configure an XMLReader object instance and call the setXMLReader(XMLReader)method

Parameters
name:String

is the SAX property name

value:Object

is the value of the SAX property

Exceptions
SAXException:
if the XMLReader could not be created or the property could not be changed.
setStringInternEnabledback to summary
public void setStringInternEnabled(boolean stringInternEnabled)

Sets whether String interning is enabled or disabled for element & attribute names and namespace URIs

Parameters
stringInternEnabled:boolean

DOCUMENT ME!

setStripWhitespaceTextback to summary
public void setStripWhitespaceText(boolean stripWhitespaceText)

Sets whether whitespace between element start and end tags should be ignored.

Parameters
stripWhitespaceText:boolean

New value of property stripWhitespaceText.

setValidationback to summary
public void setValidation(boolean validation)

Sets the validation mode.

Parameters
validation:boolean

indicates whether or not validation should occur.

setXMLFilterback to summary
public void setXMLFilter(XMLFilter filter)

Sets the SAX filter to be used when filtering SAX events

Parameters
filter:XMLFilter

is the SAX filter to use or null to disable filtering

setXMLReaderback to summary
public void setXMLReader(XMLReader reader)

Sets the XMLReader used to parse SAX events

Parameters
reader:XMLReader

is the XMLReader to parse SAX events

setXMLReaderClassNameback to summary
public void setXMLReaderClassName(String xmlReaderClassName) throws SAXException

Sets the class name of the XMLReader to be used to parse SAX events.

Parameters
xmlReaderClassName:String

is the class name of the XMLReader to parse SAX events

Exceptions
SAXException:
DOCUMENT ME!
org.dom4j.io back to summary

protected Class SAXReader.SAXEntityResolver

extends Object
implements EntityResolver, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.xml.sax.EntityResolver

Field Summary

Modifier and TypeField and Description
protected String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public InputSource
resolveEntity(String
The public identifier of the external entity being referenced, or null if none was supplied.
publicId
,
String
The system identifier of the external entity being referenced.
systemId
)

Implements org.xml.sax.EntityResolver.resolveEntity.

Allow the application to resolve external entities.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

uriPrefixback to summary
protected String uriPrefix

Constructor Detail

SAXEntityResolverback to summary
public SAXEntityResolver(String uriPrefix)

Method Detail

resolveEntityback to summary
public InputSource resolveEntity(String publicId, String systemId)

Implements org.xml.sax.EntityResolver.resolveEntity.

Doc from org.xml.sax.EntityResolver.resolveEntity.

Allow the application to resolve external entities.

The parser will call this method before opening any external entity except the top-level document entity. Such entities include the external DTD subset and external parameter entities referenced within the DTD (in either case, only if the parser reads external parameter entities), and external general entities referenced within the document element (if the parser reads external general entities). The application may request that the parser locate the entity itself, that it use an alternative URI, or that it use data provided by the application (as a character or byte input stream).

Application writers can use this method to redirect external system identifiers to secure and/or local URIs, to look up public identifiers in a catalogue, or to read an entity from a database or other input source (including, for example, a dialog box). Neither XML nor SAX specifies a preferred policy for using public or system IDs to resolve resources. However, SAX specifies how to interpret any InputSource returned by this method, and that if none is returned, then the system ID will be dereferenced as a URL.

If the system identifier is a URL, the SAX parser must resolve it fully before reporting it to the application.

Parameters
publicId:String

The public identifier of the external entity being referenced, or null if none was supplied.

systemId:String

The system identifier of the external entity being referenced.

Returns:InputSource

An InputSource object describing the new input source, or null to request that the parser open a regular URI connection to the system identifier.