Top Description Fields Constructors Methods
org.jdom.input

public Class SAXHandler

extends DefaultHandler
implements LexicalHandler, DeclHandler, DTDHandler
Class Inheritance
All Implemented Interfaces
org.xml.sax.DTDHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.ext.LexicalHandler
Known Direct Subclasses
org.jdom.transform.JDOMResult.FragmentHandler
Imports
java.util.ArrayList, .HashMap, .HashSet, .Iterator, .List, .Map, org.jdom.Attribute, .DefaultJDOMFactory, .Document, .Element, .EntityRef, .JDOMFactory, .Namespace, .Parent, org.xml.sax.Attributes, .DTDHandler, .Locator, .SAXException, org.xml.sax.ext.DeclHandler, .LexicalHandler, org.xml.sax.helpers.DefaultHandler

A support class for SAXBuilder.
Authors
Brett McLaughlin, Jason Hunter, Philip Nelson, Bradley S. Huffman, [email protected]
Version
$Revision: 1.73 $, $Date: 2007/11/10 05:29:00 $

Field Summary

Modifier and TypeField and Description
private boolean
atRoot

Indicator of where in the document we are

private static final Map<K, V>
attrNameToTypeMap

Hash table to map SAX attribute type names to JDOM attribute types.

private Element
currentElement

Element object being built

private static final String
private List<E>
declaredNamespaces

Temporary holder for namespaces that have been declared with startPrefixMapping, but are not yet available on the element

private Document
document

Document object being built

private int
entityDepth

How many nested entities we're currently within

private boolean
expand

Indicator of whether we should expand entities

private Map<K, V>
externalEntities

The external entities defined in this document

private JDOMFactory
factory

The JDOMFactory used for JDOM object creation

private boolean
ignoringBoundaryWhite

Whether to ignore text containing all whitespace

private boolean
ignoringWhite

Whether to ignore ignorable whitespace

private boolean
inCDATA

Indicator of whether we are in a CDATA

private boolean
inDTD

Indicator of whether we are in the DocType.

private boolean
inInternalSubset

Indicator of whether we are in the internal subset

private StringBuffer
internalSubset

Temporary holder for the internal subset

private Locator
locator

The SAX Locator object provided by the parser

private boolean
previousCDATA

Indicator of whether we previously were in a CDATA

private boolean
suppress

Indicator of whether we are actively suppressing (non-expanding) a current entity

private TextBuffer
textBuffer

Temporary holder for Text and CDATA

Constructor Summary

AccessConstructor and Description
public
SAXHandler()

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

public
SAXHandler(JDOMFactory
JDOMFactory to be used for constructing objects
factory
)

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

Method Summary

Modifier and TypeMethod and Description
private void
appendExternalId(String
the public ID
publicID
,
String
the system ID
systemID
)

Appends an external ID to the internal subset buffer.

public void
attributeDecl(String
String element name of attribute
eName
,
String
String attribute name
aName
,
String
String attribute type
type
,
String
String default value of attribute
valueDefault
,
String
String value of attribute
value
)

Implements org.xml.sax.ext.DeclHandler.attributeDecl.

This handles an attribute declaration in the internal subset.
public void
characters(char[]
char[] character array with character data
ch
,
int
int index in array where data starts.
start
,
int
int length of data.
length
)

Overrides org.xml.sax.helpers.DefaultHandler.characters.

Implements org.xml.sax.ContentHandler.characters.

This will report character data (within an element).
public void
comment(char[]
ch[] array of comment characters.
ch
,
int
int index to start reading from.
start
,
int
int length of data.
length
)

Implements org.xml.sax.ext.LexicalHandler.comment.

This reports that a comments is parsed.
public void
elementDecl(String
String name of element
name
,
String
String model of the element in DTD syntax
model
)

Implements org.xml.sax.ext.DeclHandler.elementDecl.

Handle an element declaration in a DTD.
public void
endCDATA()

Implements org.xml.sax.ext.LexicalHandler.endCDATA.

Report a CDATA section
public void
endDTD()

Implements org.xml.sax.ext.LexicalHandler.endDTD.

This signifies that the reading of the DTD is complete.
public void
endElement(String
String URI of namespace this element is associated with
namespaceURI
,
String
String name of element without prefix
localName
,
String
String name of element in XML 1.0 form
qName
)

Overrides org.xml.sax.helpers.DefaultHandler.endElement.

Implements org.xml.sax.ContentHandler.endElement.

Indicates the end of an element (</[element name]>) is reached.
public void
endEntity(String
The name of the entity that is ending.
name
)

Implements org.xml.sax.ext.LexicalHandler.endEntity.

Report the end of an entity.
public void
externalEntityDecl(String
entity name
name
,
String
public id
publicID
,
String
system id
systemID
)

Implements org.xml.sax.ext.DeclHandler.externalEntityDecl.

This is called when the parser encounters an external entity declaration.
protected void
flushCharacters()

This will flush any characters from SAX character calls we've been buffering.

protected void
flushCharacters(String
string to flush
data
)

Flush the given string into the document.

private static int

Returns:

int the JDOM attribute type.
getAttributeType
(String
String the SAX 2.0 attribute type string.
typeName
)

Returns the the JDOM Attribute type value from the SAX 2.0 attribute type string provided by the parser.

public Element

Returns:

Element - element being built.
getCurrentElement
()

Returns the being-parsed element.

public Document

Returns:

Document - Document that was built
getDocument
()

Returns the document.

public Locator

Returns:

Locator an object that can return the location of any SAX document event.
getDocumentLocator
()

Provides access to the Locator object provided by the SAX parser.

public boolean

Returns:

boolean - whether entity expansion will occur during build.
getExpandEntities
()

Returns whether or not entities will be expanded during the build.

public JDOMFactory

Returns:

JDOMFactory - the factory used for constructing objects.
getFactory
()

Returns the factory used for constructing objects.

public boolean

Returns:

boolean - whether only whitespace content will be ignored during build.
getIgnoringBoundaryWhitespace
()

Returns whether or not the parser will elminate element content containing only whitespace.

public boolean

Returns:

boolean - whether ignorable whitespace will be ignored during build.
getIgnoringElementContentWhitespace
()

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

public void
ignorableWhitespace(char[]
[] - char array of ignorable whitespace
ch
,
int
int - starting position within array
start
,
int
int - length of whitespace after start
length
)

Overrides org.xml.sax.helpers.DefaultHandler.ignorableWhitespace.

Implements org.xml.sax.ContentHandler.ignorableWhitespace.

Capture ignorable whitespace as text.
public void
internalEntityDecl(String
String name of entity
name
,
String
String value of the entity
value
)

Implements org.xml.sax.ext.DeclHandler.internalEntityDecl.

Handle an internal entity declaration in a DTD.
public void
notationDecl(String
name of the notation
name
,
String
the public ID of the notation
publicID
,
String
the system ID of the notation
systemID
)

Overrides org.xml.sax.helpers.DefaultHandler.notationDecl.

Implements org.xml.sax.DTDHandler.notationDecl.

Handle the declaration of a Notation in a DTD
public void
processingInstruction(String
String target of PI
target
,
String
String containing all data sent to the PI. This typically looks like one or more attribute value pairs.
data
)

Overrides org.xml.sax.helpers.DefaultHandler.processingInstruction.

Implements org.xml.sax.ContentHandler.processingInstruction.

This will indicate that a processing instruction has been encountered.
protected void
pushElement(Element
root element under which content will be built
element
)

Pushes an element onto the tree under construction.

public void
setDocumentLocator(Locator
Locator an object that can return the location of any SAX document event.
locator
)

Overrides org.xml.sax.helpers.DefaultHandler.setDocumentLocator.

Implements org.xml.sax.ContentHandler.setDocumentLocator.

Receives an object for locating the origin of SAX document events.
public void
setExpandEntities(boolean
boolean indicating whether entity expansion should occur.
expand
)

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

public void
setIgnoringBoundaryWhitespace(boolean
Whether to ignore only whitespace content
ignoringBoundaryWhite
)

Specifies whether or not the parser should elminate text() nodes containing only whitespace when building the document.

public void
setIgnoringElementContentWhitespace(boolean
Whether to ignore ignorable whitespace
ignoringWhite
)

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

public void
skippedEntity(String
String name of entity
name
)

Overrides org.xml.sax.helpers.DefaultHandler.skippedEntity.

Implements org.xml.sax.ContentHandler.skippedEntity.

This indicates that an unresolvable entity reference has been encountered, normally because the external DTD subset has not been read.
public void
startCDATA()

Implements org.xml.sax.ext.LexicalHandler.startCDATA.

Report a CDATA section
public void
startDocument()

Overrides org.xml.sax.helpers.DefaultHandler.startDocument.

Implements org.xml.sax.ContentHandler.startDocument.

Receive notification of the beginning of the document.
public void
startDTD(String
String name of element listed in DTD
name
,
String
String public ID of DTD
publicID
,
String
String system ID of DTD
systemID
)

Implements org.xml.sax.ext.LexicalHandler.startDTD.

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.
public void
startElement(String
String namespace URI this element is associated with, or an empty String
namespaceURI
,
String
String name of element (with no namespace prefix, if one is present)
localName
,
String
String XML 1.0 version of element name: [namespace prefix]:[localName]
qName
,
Attributes
Attributes list for this element
atts
)

Overrides org.xml.sax.helpers.DefaultHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

This reports the occurrence of an actual element.
public void
startEntity(String
The name of the entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be "[dtd]".
name
)

Implements org.xml.sax.ext.LexicalHandler.startEntity.

Report the beginning of some internal and external XML entities.
public void
startPrefixMapping(String
String namespace prefix.
prefix
,
String
String namespace URI.
uri
)

Overrides org.xml.sax.helpers.DefaultHandler.startPrefixMapping.

Implements org.xml.sax.ContentHandler.startPrefixMapping.

This will add the prefix mapping to the JDOM Document object.
private void
transferNamespaces(Element
Element to read namespaces from.
element
)

This will take the supplied Element and transfer its namespaces to the global namespace storage.

public void
unparsedEntityDecl(String
String of the unparsed entity decl
name
,
String
String of the unparsed entity decl
publicID
,
String
String of the unparsed entity decl
systemID
,
String
String of the unparsed entity decl
notationName
)

Overrides org.xml.sax.helpers.DefaultHandler.unparsedEntityDecl.

Implements org.xml.sax.DTDHandler.unparsedEntityDecl.

Handler for unparsed entity declarations in the DTD
Inherited from org.xml.sax.helpers.DefaultHandler:
endDocumentendPrefixMappingerrorfatalErrorresolveEntitywarning

Field Detail

atRootback to summary
private boolean atRoot

Indicator of where in the document we are

attrNameToTypeMapback to summary
private static final Map<K, V> attrNameToTypeMap

Hash table to map SAX attribute type names to JDOM attribute types.

currentElementback to summary
private Element currentElement

Element object being built

CVS_IDback to summary
private static final String CVS_ID
declaredNamespacesback to summary
private List<E> declaredNamespaces

Temporary holder for namespaces that have been declared with startPrefixMapping, but are not yet available on the element

documentback to summary
private Document document

Document object being built

entityDepthback to summary
private int entityDepth

How many nested entities we're currently within

expandback to summary
private boolean expand

Indicator of whether we should expand entities

externalEntitiesback to summary
private Map<K, V> externalEntities

The external entities defined in this document

factoryback to summary
private JDOMFactory factory

The JDOMFactory used for JDOM object creation

ignoringBoundaryWhiteback to summary
private boolean ignoringBoundaryWhite

Whether to ignore text containing all whitespace

ignoringWhiteback to summary
private boolean ignoringWhite

Whether to ignore ignorable whitespace

inCDATAback to summary
private boolean inCDATA

Indicator of whether we are in a CDATA

inDTDback to summary
private boolean inDTD

Indicator of whether we are in the DocType. Note that the DTD consists of both the internal subset (inside the <!DOCTYPE> tag) and the external subset (in a separate .dtd file).

inInternalSubsetback to summary
private boolean inInternalSubset

Indicator of whether we are in the internal subset

internalSubsetback to summary
private StringBuffer internalSubset

Temporary holder for the internal subset

locatorback to summary
private Locator locator

The SAX Locator object provided by the parser

previousCDATAback to summary
private boolean previousCDATA

Indicator of whether we previously were in a CDATA

suppressback to summary
private boolean suppress

Indicator of whether we are actively suppressing (non-expanding) a current entity

textBufferback to summary
private TextBuffer textBuffer

Temporary holder for Text and CDATA

Constructor Detail

SAXHandlerback to summary
public SAXHandler()

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.

SAXHandlerback to summary
public SAXHandler(JDOMFactory factory)

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

JDOMFactory to be used for constructing objects

Method Detail

appendExternalIdback to summary
private void appendExternalId(String publicID, String systemID)

Appends an external ID to the internal subset buffer. Either publicID or systemID may be null, but not both.

Parameters
publicID:String

the public ID

systemID:String

the system ID

attributeDeclback to summary
public void attributeDecl(String eName, String aName, String type, String valueDefault, String value) throws SAXException

Implements org.xml.sax.ext.DeclHandler.attributeDecl.

This handles an attribute declaration in the internal subset.

Parameters
eName:String

String element name of attribute

aName:String

String attribute name

type:String

String attribute type

valueDefault:String

String default value of attribute

value:String

String value of attribute

Exceptions
SAXException:

Doc from org.xml.sax.ext.DeclHandler.attributeDecl.

The application may raise an exception.

charactersback to summary
public void characters(char[] ch, int start, int length) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.characters.

Implements org.xml.sax.ContentHandler.characters.

This will report character data (within an element).

Parameters
ch:char[]

char[] character array with character data

start:int

int index in array where data starts.

length:int

int length of data.

Exceptions
SAXException:

Doc from org.xml.sax.helpers.DefaultHandler.characters.

Any SAX exception, possibly wrapping another exception.

commentback to summary
public void comment(char[] ch, int start, int length) throws SAXException

Implements org.xml.sax.ext.LexicalHandler.comment.

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:char[]

ch[] array of comment characters.

start:int

int index to start reading from.

length:int

int length of data.

Exceptions
SAXException:

Doc from org.xml.sax.ext.LexicalHandler.comment.

The application may raise an exception.

elementDeclback to summary
public void elementDecl(String name, String model) throws SAXException

Implements org.xml.sax.ext.DeclHandler.elementDecl.

Handle an element declaration in a DTD.

Parameters
name:String

String name of element

model:String

String model of the element in DTD syntax

Exceptions
SAXException:

Doc from org.xml.sax.ext.DeclHandler.elementDecl.

The application may raise an exception.

endCDATAback to summary
public void endCDATA() throws SAXException

Implements org.xml.sax.ext.LexicalHandler.endCDATA.

Report a CDATA section

Exceptions
SAXException:

Doc from org.xml.sax.ext.LexicalHandler.endCDATA.

The application may raise an exception.

endDTDback to summary
public void endDTD() throws SAXException

Implements org.xml.sax.ext.LexicalHandler.endDTD.

This signifies that the reading of the DTD is complete.

Exceptions
SAXException:

Doc from org.xml.sax.ext.LexicalHandler.endDTD.

The application may raise an exception.

endElementback to summary
public void endElement(String namespaceURI, String localName, String qName) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.endElement.

Implements org.xml.sax.ContentHandler.endElement.

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

String URI of namespace this element is associated with

localName:String

String name of element without prefix

qName:String

String name of element in XML 1.0 form

Exceptions
SAXException:
when things go wrong
endEntityback to summary
public void endEntity(String name) throws SAXException

Implements org.xml.sax.ext.LexicalHandler.endEntity.

Doc from org.xml.sax.ext.LexicalHandler.endEntity.

Report the end of an entity.

Parameters
name:String

The name of the entity that is ending.

Exceptions
SAXException:
The application may raise an exception.
externalEntityDeclback to summary
public void externalEntityDecl(String name, String publicID, String systemID) throws SAXException

Implements org.xml.sax.ext.DeclHandler.externalEntityDecl.

This is called when the parser encounters an external entity declaration.

Parameters
name:String

entity name

publicID:String

public id

systemID:String

system id

Exceptions
SAXException:
when things go wrong
flushCharactersback to summary
protected void flushCharacters() throws SAXException

This will flush any characters from SAX character calls we've been buffering.

Exceptions
SAXException:
when things go wrong
flushCharactersback to summary
protected void flushCharacters(String data) throws SAXException

Flush the given string into the document. This is a protected method so subclassers can control text handling without knowledge of the internals of this class.

Parameters
data:String

string to flush

getAttributeTypeback to summary
private static int getAttributeType(String typeName)

Returns the the JDOM Attribute type value from the SAX 2.0 attribute type string provided by the parser.

Parameters
typeName:String

String the SAX 2.0 attribute type string.

Returns:int

int the JDOM attribute type.

See Also
Attribute#setAttributeType, Attributes#getType
getCurrentElementback to summary
public Element getCurrentElement() throws SAXException

Returns the being-parsed element.

Returns:Element

Element - element being built.

getDocumentback to summary
public Document getDocument()

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

Returns:Document

Document - Document that was built

getDocumentLocatorback to summary
public Locator getDocumentLocator()

Provides access to the Locator object provided by the SAX parser.

Returns:Locator

Locator an object that can return the location of any SAX document event.

getExpandEntitiesback to summary
public boolean getExpandEntities()

Returns whether or not entities will be expanded during the build.

Returns:boolean

boolean - whether entity expansion will occur during build.

See Also
setExpandEntities
getFactoryback to summary
public JDOMFactory getFactory()

Returns the factory used for constructing objects.

Returns:JDOMFactory

JDOMFactory - the factory used for constructing objects.

See Also
SAXHandler(org.jdom.JDOMFactory)
getIgnoringBoundaryWhitespaceback to summary
public boolean getIgnoringBoundaryWhitespace()

Returns whether or not the parser will elminate element content containing only whitespace.

Returns:boolean

boolean - whether only whitespace content will be ignored during build.

See Also
setIgnoringBoundaryWhitespace
getIgnoringElementContentWhitespaceback to summary
public boolean getIgnoringElementContentWhitespace()

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

Returns:boolean

boolean - whether ignorable whitespace will be ignored during build.

See Also
setIgnoringElementContentWhitespace
ignorableWhitespaceback to summary
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.ignorableWhitespace.

Implements org.xml.sax.ContentHandler.ignorableWhitespace.

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

Parameters
ch:char[]

[] - char array of ignorable whitespace

start:int

int - starting position within array

length:int

int - length of whitespace after start

Exceptions
SAXException:
when things go wrong
internalEntityDeclback to summary
public void internalEntityDecl(String name, String value) throws SAXException

Implements org.xml.sax.ext.DeclHandler.internalEntityDecl.

Handle an internal entity declaration in a DTD.

Parameters
name:String

String name of entity

value:String

String value of the entity

Exceptions
SAXException:

Doc from org.xml.sax.ext.DeclHandler.internalEntityDecl.

The application may raise an exception.

notationDeclback to summary
public void notationDecl(String name, String publicID, String systemID) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.notationDecl.

Implements org.xml.sax.DTDHandler.notationDecl.

Handle the declaration of a Notation in a DTD

Parameters
name:String

name of the notation

publicID:String

the public ID of the notation

systemID:String

the system ID of the notation

Exceptions
SAXException:

Doc from org.xml.sax.DTDHandler.notationDecl.

Any SAX exception, possibly wrapping another exception.

processingInstructionback to summary
public void processingInstruction(String target, String data) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.processingInstruction.

Implements org.xml.sax.ContentHandler.processingInstruction.

This will indicate that a processing instruction has been encountered. (The XML declaration is not a processing instruction and will not be reported.)

Parameters
target:String

String target of PI

data:String

String containing all data sent to the PI. This typically looks like one or more attribute value pairs.

Exceptions
SAXException:
when things go wrong
pushElementback to summary
protected void pushElement(Element element)

Pushes an element onto the tree under construction. Allows subclasses to put content under a dummy root element which is useful for building content that would otherwise be a non-well formed document.

Parameters
element:Element

root element under which content will be built

setDocumentLocatorback to summary
public void setDocumentLocator(Locator locator)

Overrides org.xml.sax.helpers.DefaultHandler.setDocumentLocator.

Implements org.xml.sax.ContentHandler.setDocumentLocator.

Receives an object for locating the origin of SAX document events. This method is invoked by the SAX parser.

org.jdom.JDOMFactory implementations can use the getDocumentLocator method to get access to the Locator during parse.

Parameters
locator:Locator

Locator an object that can return the location of any SAX document event.

setExpandEntitiesback to summary
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

boolean indicating whether entity expansion should occur.

setIgnoringBoundaryWhitespaceback to summary
public void setIgnoringBoundaryWhitespace(boolean ignoringBoundaryWhite)

Specifies whether or not the parser should elminate text() nodes containing only whitespace when building the document. See SAXBuilder#setIgnoringBoundaryWhitespace(boolean).

Parameters
ignoringBoundaryWhite:boolean

Whether to ignore only whitespace content

setIgnoringElementContentWhitespaceback to summary
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:boolean

Whether to ignore ignorable whitespace

skippedEntityback to summary
public void skippedEntity(String name) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.skippedEntity.

Implements org.xml.sax.ContentHandler.skippedEntity.

This indicates that an unresolvable entity reference has been encountered, normally because the external DTD subset has not been read.

Parameters
name:String

String name of entity

Exceptions
SAXException:
when things go wrong
startCDATAback to summary
public void startCDATA() throws SAXException

Implements org.xml.sax.ext.LexicalHandler.startCDATA.

Report a CDATA section

Exceptions
SAXException:

Doc from org.xml.sax.ext.LexicalHandler.startCDATA.

The application may raise an exception.

startDocumentback to summary
public void startDocument()

Overrides org.xml.sax.helpers.DefaultHandler.startDocument.

Implements org.xml.sax.ContentHandler.startDocument.

Doc from org.xml.sax.helpers.DefaultHandler.startDocument.

Receive notification of the beginning of the document.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the beginning of a document (such as allocating the root node of a tree or creating an output file).

startDTDback to summary
public void startDTD(String name, String publicID, String systemID) throws SAXException

Implements org.xml.sax.ext.LexicalHandler.startDTD.

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

String name of element listed in DTD

publicID:String

String public ID of DTD

systemID:String

String system ID of DTD

Exceptions
SAXException:

Doc from org.xml.sax.ext.LexicalHandler.startDTD.

The application may raise an exception.

startElementback to summary
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

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

String namespace URI this element is associated with, or an empty String

localName:String

String name of element (with no namespace prefix, if one is present)

qName:String

String XML 1.0 version of element name: [namespace prefix]:[localName]

atts:Attributes

Attributes list for this element

Exceptions
SAXException:
when things go wrong
startEntityback to summary
public void startEntity(String name) throws SAXException

Implements org.xml.sax.ext.LexicalHandler.startEntity.

Doc from org.xml.sax.ext.LexicalHandler.startEntity.

Report the beginning of some internal and external XML entities.

The reporting of parameter entities (including the external DTD subset) is optional, and SAX2 drivers that report LexicalHandler events may not implement it; you can use the http://xml.org/sax/features/lexical-handler/parameter-entities feature to query or control the reporting of parameter entities.

General entities are reported with their regular names, parameter entities have '%' prepended to their names, and the external DTD subset has the pseudo-entity name "[dtd]".

When a SAX2 driver is providing these events, all other events must be properly nested within start/end entity events. There is no additional requirement that events from DeclHandler or DTDHandler be properly ordered.

Note that skipped entities will be reported through the skippedEntity event, which is part of the ContentHandler interface.

Because of the streaming event model that SAX uses, some entity boundaries cannot be reported under any circumstances:

  • general entities within attribute values
  • parameter entities within declarations

These will be silently expanded, with no indication of where the original entity boundaries were.

Note also that the boundaries of character references (which are not really entities anyway) are not reported.

All start/endEntity events must be properly nested.

Parameters
name:String

The name of the entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be "[dtd]".

Exceptions
SAXException:
The application may raise an exception.
startPrefixMappingback to summary
public void startPrefixMapping(String prefix, String uri) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.startPrefixMapping.

Implements org.xml.sax.ContentHandler.startPrefixMapping.

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

Parameters
prefix:String

String namespace prefix.

uri:String

String namespace URI.

Exceptions
SAXException:

Doc from org.xml.sax.helpers.DefaultHandler.startPrefixMapping.

Any SAX exception, possibly wrapping another exception.

transferNamespacesback to summary
private void transferNamespaces(Element element)

This will take the supplied Element and transfer its namespaces to the global namespace storage.

Parameters
element:Element

Element to read namespaces from.

unparsedEntityDeclback to summary
public void unparsedEntityDecl(String name, String publicID, String systemID, String notationName) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.unparsedEntityDecl.

Implements org.xml.sax.DTDHandler.unparsedEntityDecl.

Handler for unparsed entity declarations in the DTD

Parameters
name:String

String of the unparsed entity decl

publicID:String

String of the unparsed entity decl

systemID:String

String of the unparsed entity decl

notationName:String

String of the unparsed entity decl

Exceptions
SAXException:

Doc from org.xml.sax.DTDHandler.unparsedEntityDecl.

Any SAX exception, possibly wrapping another exception.