All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.jdom.input.SAXHandler

java.lang.Object
   |
   +----org.xml.sax.helpers.DefaultHandler
           |
           +----org.jdom.input.SAXHandler

public class SAXHandler
extends DefaultHandler
implements LexicalHandler, DeclHandler

SAXHandler supports SAXBuilder

Author:
Brett McLaughlin, Jason Hunter

Constructor Index

 o SAXHandler()

This will create a new SAXHandler that listens to SAX events and creates a JDOM Document.

 o SAXHandler(Document)

This will set the Document to use. Deprecated.

 o SAXHandler(JDOMFactory)

This will create a new SAXHandler that listens to SAX events and creates a JDOM Document.

Method Index

 o attributeDecl(String, String, String, String, String)
 o characters(char[], int, int)

This will report character data (within an element).

 o comment(char[], int, int)

This reports that a comments is parsed.

 o elementDecl(String, String)
 o endCDATA()

Report a CDATA section - ignored in SAXBuilder.

 o endDTD()

This signifies that the reading of the DTD is complete.

 o endElement(String, String, String)

Indicates the end of an element (</[element name]>) is reached.

 o endEntity(String)
 o endPrefixMapping(String)

This will add the prefix mapping to the JDOM Document object.

 o externalEntityDecl(String, String, String)
This is called when the parser encounters an external entity declaration.
 o getDocument()

Returns the document.

 o ignorableWhitespace(char[], int, int)

Capture ignorable whitespace as text.

 o internalEntityDecl(String, String)
 o processingInstruction(String, String)

This will indicate that a processing instruction (other than the XML declaration) has been encountered.

 o setExpandEntities(boolean)

This sets whether or not to expand entities during the build.

 o setIgnoringElementContentWhitespace(boolean)

Specifies whether or not the parser should elminate whitespace in element content (sometimes known as "ignorable whitespace") when building the document.

 o startCDATA()

Report a CDATA section - ignored in SAXBuilder.

 o startDTD(String, String, String)

This will signify that a DTD is being parsed, and can be used to ensure that comments and other lexical structures in the DTD are not added to the JDOM Document object.

 o startElement(String, String, String, Attributes)

This reports the occurrence of an actual element.

 o startEntity(String)
 o startPrefixMapping(String, String)

This will add the prefix mapping to the JDOM Document object.

Constructors

 o SAXHandler
 public SAXHandler(Document document) throws IOException
Note: SAXHandler() is deprecated. Deprecated in beta7, use SAXHandler() instead and let SAXHandler create the Document, then retrieve it with getDocument()

This will set the Document to use.

Parameters:
document - Document being parsed.
Throws: IOException
when errors occur.
 o SAXHandler
 public SAXHandler() throws IOException

This will create a new SAXHandler that listens to SAX events and creates a JDOM Document. The objects will be constructed using the default factory.

Throws: IOException
when errors occur.
 o SAXHandler
 public SAXHandler(JDOMFactory factory) throws IOException

This will create a new SAXHandler that listens to SAX events and creates a JDOM Document. The objects will be constructed using the provided factory.

Parameters:
factory - JDOMFactory to be used for constructing objects
Throws: IOException
when errors occur.

Methods

 o getDocument
 public Document getDocument()

Returns the document. Should be called after parsing is complete.

Returns:
Document - Document that was built
 o setExpandEntities
 public void setExpandEntities(boolean expand)

This sets whether or not to expand entities during the build. A true means to expand entities as normal content. A false means to leave entities unexpanded as EntityRef objects. The default is true.

Parameters:
expand - boolean indicating whether entity expansion should occur.
 o setIgnoringElementContentWhitespace
 public void setIgnoringElementContentWhitespace(boolean ignoringWhite)

Specifies whether or not the parser should elminate whitespace in element content (sometimes known as "ignorable whitespace") when building the document. Only whitespace which is contained within element content that has an element only content model will be eliminated (see XML Rec 3.2.1). For this setting to take effect requires that validation be turned on. The default value of this setting is false.

Parameters:
ignoringWhite - Whether to ignore ignorable whitespace
 o externalEntityDecl
 public void externalEntityDecl(String name,
                                String publicId,
                                String systemId) throws SAXException
This is called when the parser encounters an external entity declaration.

Parameters:
name - entity name
publicId - public id
systemId - system id
Throws: SAXException
when things go wrong
 o attributeDecl
 public void attributeDecl(String eName,
                           String aName,
                           String type,
                           String valueDefault,
                           String value)
 o elementDecl
 public void elementDecl(String name,
                         String model)
 o internalEntityDecl
 public void internalEntityDecl(String name,
                                String value)
 o processingInstruction
 public void processingInstruction(String target,
                                   String data) throws SAXException

This will indicate that a processing instruction (other than the XML declaration) has been encountered.

Parameters:
target - String target of PI
data - String Throws: SAXException
when things go wrong
Overrides:
processingInstruction in class DefaultHandler
 o startPrefixMapping
 public void startPrefixMapping(String prefix,
                                String uri) throws SAXException

This will add the prefix mapping to the JDOM Document object.

Parameters:
prefix - String namespace prefix.
uri - String namespace URI.
Overrides:
startPrefixMapping in class DefaultHandler
 o endPrefixMapping
 public void endPrefixMapping(String prefix) throws SAXException

This will add the prefix mapping to the JDOM Document object.

Parameters:
prefix - String namespace prefix.
uri - String namespace URI.
Overrides:
endPrefixMapping in class DefaultHandler
 o startElement
 public void startElement(String namespaceURI,
                          String localName,
                          String qName,
                          Attributes atts) throws SAXException

This reports the occurrence of an actual element. It will include the element's attributes, with the exception of XML vocabulary specific attributes, such as xmlns:[namespace prefix] and xsi:schemaLocation.

Parameters:
namespaceURI - String namespace URI this element is associated with, or an empty String
localName - String name of element (with no namespace prefix, if one is present)
qName - String XML 1.0 version of element name: [namespace prefix]:[localName]
atts - Attributes list for this element
Throws: SAXException
when things go wrong
Overrides:
startElement in class DefaultHandler
 o characters
 public void characters(char ch[],
                        int start,
                        int length) throws SAXException

This will report character data (within an element).

Parameters:
ch - char[] character array with character data
start - int index in array where data starts.
length - int length of data.
Throws: SAXException
when things go wrong
Overrides:
characters in class DefaultHandler
 o ignorableWhitespace
 public void ignorableWhitespace(char ch[],
                                 int start,
                                 int length) throws SAXException

Capture ignorable whitespace as text. If setIgnoringElementContentWhitespace(true) has been called then this method does nothing.

Parameters:
ch - [] - char array of ignorable whitespace
start - int - starting position within array
length - int - length of whitespace after start
Throws: SAXException
when things go wrong
Overrides:
ignorableWhitespace in class DefaultHandler
 o endElement
 public void endElement(String namespaceURI,
                        String localName,
                        String qName) throws SAXException

Indicates the end of an element (</[element name]>) is reached. Note that the parser does not distinguish between empty elements and non-empty elements, so this will occur uniformly.

Parameters:
namespaceURI - String URI of namespace this element is associated with
localName - String name of element without prefix
qName - String name of element in XML 1.0 form
Throws: SAXException
when things go wrong
Overrides:
endElement in class DefaultHandler
 o startDTD
 public void startDTD(String name,
                      String publicId,
                      String systemId) throws SAXException

This will signify that a DTD is being parsed, and can be used to ensure that comments and other lexical structures in the DTD are not added to the JDOM Document object.

Parameters:
name - String name of element listed in DTD
publicId - String public ID of DTD
systemId - String syste ID of DTD
 o endDTD
 public void endDTD() throws SAXException

This signifies that the reading of the DTD is complete.

 o startEntity
 public void startEntity(String name) throws SAXException
 o endEntity
 public void endEntity(String name) throws SAXException
 o startCDATA
 public void startCDATA() throws SAXException

Report a CDATA section - ignored in SAXBuilder.

 o endCDATA
 public void endCDATA() throws SAXException

Report a CDATA section - ignored in SAXBuilder.

 o comment
 public void comment(char ch[],
                     int start,
                     int length) throws SAXException

This reports that a comments is parsed. If not in the DTD, this comment is added to the current JDOM Element, or the Document itself if at that level.

Parameters:
ch - ch[] array of comment characters.
start - int index to start reading from.
length - int length of data.

All Packages  Class Hierarchy  This Package  Previous  Next  Index