Top Description Fields Constructors Methods
org.jdom2.input.sax

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.jdom2.transform.JDOMResult.FragmentHandler, org.jdom2.input.sax.DefaultSAXHandlerFactory.DefaultSAXHandler
Imports
java.util.ArrayList, .HashMap, .List, .Map, javax.xml.XMLConstants, org.xml.sax.Attributes, .DTDHandler, .Locator, .SAXException, org.xml.sax.ext.Attributes2, .DeclHandler, .LexicalHandler, org.xml.sax.helpers.DefaultHandler, org.jdom2.Attribute, .AttributeType, .CDATA, .Comment, .DefaultJDOMFactory, .DocType, .Document, .Element, .EntityRef, .JDOMFactory, .Namespace, .Parent, .ProcessingInstruction, .Text, org.jdom2.input.SAXBuilder

A support class for SAXBuilder which listens for SAX events.

People overriding this class are cautioned to ensure that the implementation of the cleanUp() method resets to a virgin state. The cleanUp() method will be called when this SAXHandler is reset(), which may happen multiple times between parses. The cleanUp() method must ensure that there are no references remaining to any external instances.

Overriding of this class is permitted to allow for different handling of SAX events. Once you have created a subclass of this, you also need to create a custom implementation of SAXHandlerFactory to supply your instances to SAXBuilder

If the XMLReader producing the SAX Events supports a document Locator, then this instance will use the locator to supply the line and column data from the SAX locator to the JDOMFactory

Note

the SAX specification for the SAX Locator indicates that the line and column represent the position of the end of the SAX Event. For example, the line and column of the simple XML <root /> would be line 1, column 9.

Authors
Brett McLaughlin, Jason Hunter, Philip Nelson, Bradley S. Huffman, [email protected], Rolf Lear
See Also
org.jdom2.input.sax

Field Summary

Modifier and TypeField and Description
private boolean
atRoot

Indicator of where in the document we are - must be reset()

private Document
currentDocument

Document object being built - must be cleared on reset()

private Element
currentElement

Element object being built - must be cleared on reset()

private Locator
currentLocator

The SAX Locator object provided by the parser

private final List<Namespace>
declaredNamespaces

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

private int
entityDepth

How many nested entities we're currently within - must be reset()

private boolean
expand

Indicator of whether we should expand entities - must be reset()

private final Map<String, String[]>
externalEntities

The external entities defined in this document

private final 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 - must be reset()

private boolean
inDTD

Indicator of whether we are in the DocType.

private boolean
inInternalSubset

Indicator of whether we are in the internal subset - must be reset()

private final StringBuilder
internalSubset

Temporary holder for the internal subset

private int
private int
private boolean
previousCDATA

Indicator of whether we previously were in a CDATA - must be reset()

private boolean
suppress

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

private final 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(final 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(final String
the public ID
publicID
,
final String
the system ID
systemID
)

Appends an external ID to the internal subset buffer.

public void
attributeDecl(final String
String element name of attribute
eName
,
final String
String attribute name
aName
,
final String
String attribute type
type
,
final String
String default value of attribute
valueDefault
,
final 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(final char[]
char[] character array with character data
ch
,
final int
int index in array where data starts.
start
,
final 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(final char[]
ch[] array of comment characters.
ch
,
final int
int index to start reading from.
start
,
final int
int length of data.
length
)

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

This reports that a comments is parsed.
public void
elementDecl(final String
String name of element
name
,
final 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(final String
String URI of namespace this element is associated with
namespaceURI
,
final String
String name of element without prefix
localName
,
final 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(final 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(final String
entity name
name
,
final String
public id
publicID
,
final 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(final String
string to flush
data
)

Flush the given string into the document.

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 eliminate 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 eliminate whitespace in element content (sometimes known as "ignorable whitespace") when building the document.

public void
ignorableWhitespace(final char[]
[] - char array of ignorable whitespace
ch
,
final int
int - starting position within array
start
,
final 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(final String
String name of entity
name
,
final 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(final String
name of the notation
name
,
final String
the public ID of the notation
publicID
,
final 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(final String
String target of PI
target
,
final 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(final Element
root element under which content will be built
element
)

Pushes an element onto the tree under construction.

public final void
reset()

Restore this SAXHandler to a clean state ready for another parse round.

protected void
resetSubCLass()

Override this method if you are a subclasser, and you want to clear the state of your SAXHandler instance in preparation for a new parse.

public void
setDocumentLocator(final 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(final boolean
boolean indicating whether entity expansion should occur.
expand
)

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

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

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

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

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

public void
skippedEntity(final 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(final String
String name of element listed in DTD
name
,
final String
String public ID of DTD
publicID
,
final 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(final 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
,
final String
String XML 1.0 version of element name: [namespace prefix]:[localName]
qName
,
final 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(final 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(final String
String namespace prefix.
prefix
,
final 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(final 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(final String
String of the unparsed entity decl
name
,
final String
String of the unparsed entity decl
publicID
,
final String
String of the unparsed entity decl
systemID
,
final 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 - must be reset()

currentDocumentback to summary
private Document currentDocument

Document object being built - must be cleared on reset()

currentElementback to summary
private Element currentElement

Element object being built - must be cleared on reset()

currentLocatorback to summary
private Locator currentLocator

The SAX Locator object provided by the parser

declaredNamespacesback to summary
private final List<Namespace> declaredNamespaces

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

entityDepthback to summary
private int entityDepth

How many nested entities we're currently within - must be reset()

expandback to summary
private boolean expand

Indicator of whether we should expand entities - must be reset()

externalEntitiesback to summary
private final Map<String, String[]> externalEntities

The external entities defined in this document

factoryback to summary
private final 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 - must be reset()

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). - must be reset()

inInternalSubsetback to summary
private boolean inInternalSubset

Indicator of whether we are in the internal subset - must be reset()

internalSubsetback to summary
private final StringBuilder internalSubset

Temporary holder for the internal subset

lastcolback to summary
private int lastcol
lastlineback to summary
private int lastline
previousCDATAback to summary
private boolean previousCDATA

Indicator of whether we previously were in a CDATA - must be reset()

suppressback to summary
private boolean suppress

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

textBufferback to summary
private final 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(final 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(final String publicID, final 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(final String eName, final String aName, final String type, final String valueDefault, final String value)

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

Annotations
@Override
charactersback to summary
public void characters(final char[] ch, final int start, final 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.

Annotations
@Override
Exceptions
SAXException:

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

Any SAX exception, possibly wrapping another exception.

commentback to summary
public void comment(final char[] ch, final int start, final 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.

Annotations
@Override
Exceptions
SAXException:
if the state of the handler disallows this call
elementDeclback to summary
public void elementDecl(final String name, final String model)

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

Annotations
@Override
endCDATAback to summary
public void endCDATA() throws SAXException

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

Report a CDATA section

Annotations
@Override
Exceptions
SAXException:

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

The application may raise an exception.

endDTDback to summary
public void endDTD()

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

This signifies that the reading of the DTD is complete.

Annotations
@Override
endElementback to summary
public void endElement(final String namespaceURI, final String localName, final 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

Annotations
@Override
Exceptions
SAXException:
when things go wrong
endEntityback to summary
public void endEntity(final 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.

Annotations
@Override
Exceptions
SAXException:
The application may raise an exception.
externalEntityDeclback to summary
public void externalEntityDecl(final String name, final String publicID, final 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

Annotations
@Override
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(final 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

Exceptions
SAXException:
if the state of the handler does not allow this.
getCurrentElementback to summary
public Element getCurrentElement() throws SAXException

Returns the being-parsed element.

Returns:Element

Element - element being built.

Exceptions
SAXException:
if the state of the handler disallows this call
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.jdom2.JDOMFactory)
getIgnoringBoundaryWhitespaceback to summary
public boolean getIgnoringBoundaryWhitespace()

Returns whether or not the parser will eliminate 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 eliminate 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(final char[] ch, final int start, final 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

Annotations
@Override
Exceptions
SAXException:
when things go wrong
internalEntityDeclback to summary
public void internalEntityDecl(final String name, final String value)

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

Annotations
@Override
notationDeclback to summary
public void notationDecl(final String name, final String publicID, final 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

Annotations
@Override
Exceptions
SAXException:

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

Any SAX exception, possibly wrapping another exception.

processingInstructionback to summary
public void processingInstruction(final String target, final 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.

Annotations
@Override
Exceptions
SAXException:
when things go wrong
pushElementback to summary
protected void pushElement(final 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

resetback to summary
public final void reset()

Restore this SAXHandler to a clean state ready for another parse round. All internal variables are cleared to an initialized state, and then the resetSubClass() method is called to clear any methods that a subclass may need to have reset.

resetSubCLassback to summary
protected void resetSubCLass()

Override this method if you are a subclasser, and you want to clear the state of your SAXHandler instance in preparation for a new parse.

setDocumentLocatorback to summary
public void setDocumentLocator(final 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.jdom2.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.

Annotations
@Override
setExpandEntitiesback to summary
public void setExpandEntities(final 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(final boolean ignoringBoundaryWhite)

Specifies whether or not the parser should eliminate 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(final boolean ignoringWhite)

Specifies whether or not the parser should eliminate 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(final 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

Annotations
@Override
Exceptions
SAXException:
when things go wrong
startCDATAback to summary
public void startCDATA()

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

Report a CDATA section

Annotations
@Override
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).

Annotations
@Override
startDTDback to summary
public void startDTD(final String name, final String publicID, final 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

Annotations
@Override
Exceptions
SAXException:

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

The application may raise an exception.

startElementback to summary
public void startElement(final String namespaceURI, String localName, final String qName, final 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

Annotations
@Override
Exceptions
SAXException:
when things go wrong
startEntityback to summary
public void startEntity(final 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]".

Annotations
@Override
Exceptions
SAXException:
The application may raise an exception.
startPrefixMappingback to summary
public void startPrefixMapping(final String prefix, final 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.

Annotations
@Override
Exceptions
SAXException:

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

Any SAX exception, possibly wrapping another exception.

transferNamespacesback to summary
private void transferNamespaces(final 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(final String name, final String publicID, final String systemID, final String notationName)

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

Annotations
@Override