Top Description Fields Constructors Methods
org.dom4j.io

pack-priv Class SAXModifyContentHandler

extends SAXContentHandler
Class Inheritance
Imports
java.io.IOException, org.dom4j.DocumentFactory, .Element, .ElementHandler, org.xml.sax.Attributes, .Locator, .SAXException

This extension of the SAXContentHandler writes SAX events immediately to the provided XMLWriter, unless some org.dom4.ElementHandleris still handling the current Element.
Author
Wonne Keysers (Realsoftware.be)
See Also
org.dom4j.io.SAXContentHandler

Field Summary

Modifier and TypeField and Description
private XMLWriter

Constructor Summary

AccessConstructor and Description
public
public
public
SAXModifyContentHandler(DocumentFactory documentFactory, ElementHandler elementHandler)

public
SAXModifyContentHandler(DocumentFactory documentFactory, ElementHandler elementHandler, ElementStack elementStack)

Method Summary

Modifier and TypeMethod and Description
private boolean
public void
characters(char[]
The characters.
parm1
,
int
The start position in the character array.
parm2
,
int
The number of characters to use from the character array.
parm3
)

Overrides org.dom4j.io.SAXContentHandler.characters.

Implements org.xml.sax.ContentHandler.characters.

Receive notification of character data inside an element.
public void
comment(char[]
An array holding the characters in the comment.
characters
,
int
The starting position in the array.
parm2
,
int
The number of characters to use from the array.
parm3
)

Overrides org.dom4j.io.SAXContentHandler.comment.

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

Report an XML comment anywhere in the document.
public void
endCDATA()

Overrides org.dom4j.io.SAXContentHandler.endCDATA.

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

Report the end of a CDATA section.
public void
endDocument()

Overrides org.dom4j.io.SAXContentHandler.endDocument.

Implements org.xml.sax.ContentHandler.endDocument.

Receive notification of the end of the document.
public void
endDTD()

Overrides org.dom4j.io.SAXContentHandler.endDTD.

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

Report the end of DTD declarations.
public void
endElement(String
The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
uri
,
String
The local name (without prefix), or the empty string if Namespace processing is not being performed.
localName
,
String
The qualified name (with prefix), or the empty string if qualified names are not available.
qName
)

Overrides org.dom4j.io.SAXContentHandler.endElement.

Implements org.xml.sax.ContentHandler.endElement.

Receive notification of the end of an element.
public void
endEntity(String
The name of the entity that is ending.
name
)

Overrides org.dom4j.io.SAXContentHandler.endEntity.

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

Report the end of an entity.
public void
endPrefixMapping(String
The Namespace prefix being declared.
prefix
)

Overrides org.dom4j.io.SAXContentHandler.endPrefixMapping.

Implements org.xml.sax.ContentHandler.endPrefixMapping.

Receive notification of the end of a Namespace mapping.
protected XMLWriter
public void
ignorableWhitespace(char[]
The whitespace characters.
parm1
,
int
The start position in the character array.
parm2
,
int
The number of characters to use from the character array.
parm3
)

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

Implements org.xml.sax.ContentHandler.ignorableWhitespace.

Receive notification of ignorable whitespace in element content.
public void
notationDecl(String
The notation name.
name
,
String
The notation's public identifier, or null if none was given.
publicId
,
String
The notation's system identifier, or null if none was given.
systemId
)

Overrides org.dom4j.io.SAXContentHandler.notationDecl.

Implements org.xml.sax.DTDHandler.notationDecl.

Receive notification of a notation declaration event.
public void
processingInstruction(String
The processing instruction target.
target
,
String
The processing instruction data, or null if none is supplied.
data
)

Overrides org.dom4j.io.SAXContentHandler.processingInstruction.

Implements org.xml.sax.ContentHandler.processingInstruction.

Receive notification of a processing instruction.
public void
setDocumentLocator(Locator
A locator for all SAX document events.
locator
)

Overrides org.dom4j.io.SAXContentHandler.setDocumentLocator.

Implements org.xml.sax.ContentHandler.setDocumentLocator.

Receive a Locator object for document events.
public void
public void
skippedEntity(String
The name of the skipped entity.
name
)

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

Implements org.xml.sax.ContentHandler.skippedEntity.

Receive notification of a skipped entity.
public void
startCDATA()

Overrides org.dom4j.io.SAXContentHandler.startCDATA.

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

Report the start of a CDATA section.
public void
startDocument()

Overrides org.dom4j.io.SAXContentHandler.startDocument.

Implements org.xml.sax.ContentHandler.startDocument.

Receive notification of the beginning of the document.
public void
startDTD(String
The document type name.
name
,
String
The declared public identifier for the external DTD subset, or null if none was declared.
publicId
,
String
The declared system identifier for the external DTD subset, or null if none was declared. (Note that this is not resolved against the document base URI.)
systemId
)

Overrides org.dom4j.io.SAXContentHandler.startDTD.

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

Report the start of DTD declarations, if any.
public void
startElement(String
The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
uri
,
String
The local name (without prefix), or the empty string if Namespace processing is not being performed.
localName
,
String
The qualified name (with prefix), or the empty string if qualified names are not available.
qName
,
Attributes
The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
atts
)

Overrides org.dom4j.io.SAXContentHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Receive notification of the start of an 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
)

Overrides org.dom4j.io.SAXContentHandler.startEntity.

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

Report the beginning of some internal and external XML entities.
public void
startPrefixMapping(String
The Namespace prefix being declared.
prefix
,
String
The Namespace URI mapped to the prefix.
uri
)

Overrides org.dom4j.io.SAXContentHandler.startPrefixMapping.

Implements org.xml.sax.ContentHandler.startPrefixMapping.

Receive notification of the start of a Namespace mapping.
public void
unparsedEntityDecl(String
The unparsed entity's name.
name
,
String
The entity's public identifier, or null if none was given.
publicId
,
String
The entity's system identifier.
systemId
,
String
The name of the associated notation.
notation
)

Overrides org.dom4j.io.SAXContentHandler.unparsedEntityDecl.

Implements org.xml.sax.DTDHandler.unparsedEntityDecl.

Receive notification of an unparsed entity declaration event.
Inherited from org.dom4j.io.SAXContentHandler:
addAttributesaddDeclaredNamespacesaddDTDDeclarationaddExternalDTDDeclarationattributeDeclcompleteCurrentTextNodecreateDocumentcreateElementStackelementDeclerrorexternalEntityDeclfatalErrorgetDocumentgetElementStackgetEntityResolvergetInputSourceinternalEntityDeclisIgnorableEntityisIgnoreCommentsisIncludeExternalDTDDeclarationsisIncludeInternalDTDDeclarationsisMergeAdjacentTextisStripWhitespaceTextsetElementStacksetEntityResolversetIgnoreCommentssetIncludeExternalDTDDeclarationssetIncludeInternalDTDDeclarationssetInputSourcesetMergeAdjacentTextsetStripWhitespaceTextwarning

Field Detail

xmlWriterback to summary
private XMLWriter xmlWriter

Constructor Detail

SAXModifyContentHandlerback to summary
public SAXModifyContentHandler()
SAXModifyContentHandlerback to summary
public SAXModifyContentHandler(DocumentFactory documentFactory)
SAXModifyContentHandlerback to summary
public SAXModifyContentHandler(DocumentFactory documentFactory, ElementHandler elementHandler)
SAXModifyContentHandlerback to summary
public SAXModifyContentHandler(DocumentFactory documentFactory, ElementHandler elementHandler, ElementStack elementStack)

Method Detail

activeHandlersback to summary
private boolean activeHandlers()
charactersback to summary
public void characters(char[] parm1, int parm2, int parm3) throws SAXException

Overrides org.dom4j.io.SAXContentHandler.characters.

Implements org.xml.sax.ContentHandler.characters.

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

Receive notification of character data inside an element.

By default, do nothing. Application writers may override this method to take specific actions for each chunk of character data (such as adding the data to a node or buffer, or printing it to a file).

Parameters
parm1:char[]

The characters.

parm2:int

The start position in the character array.

parm3:int

The number of characters to use from the character array.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
commentback to summary
public void comment(char[] characters, int parm2, int parm3) throws SAXException

Overrides org.dom4j.io.SAXContentHandler.comment.

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

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

Report an XML comment anywhere in the document.

This callback will be used for comments inside or outside the document element, including comments in the external DTD subset (if read). Comments in the DTD must be properly nested inside start/endDTD and start/endEntity events (if used).

Parameters
characters:char[]

An array holding the characters in the comment.

parm2:int

The starting position in the array.

parm3:int

The number of characters to use from the array.

Exceptions
SAXException:
The application may raise an exception.
endCDATAback to summary
public void endCDATA() throws SAXException

Overrides org.dom4j.io.SAXContentHandler.endCDATA.

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

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

Report the end of a CDATA section.

Exceptions
SAXException:
The application may raise an exception.
endDocumentback to summary
public void endDocument() throws SAXException

Overrides org.dom4j.io.SAXContentHandler.endDocument.

Implements org.xml.sax.ContentHandler.endDocument.

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

Receive notification of the end of the document.

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

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
endDTDback to summary
public void endDTD() throws SAXException

Overrides org.dom4j.io.SAXContentHandler.endDTD.

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

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

Report the end of DTD declarations.

This method is intended to report the end of the DOCTYPE declaration; if the document has no DOCTYPE declaration, this method will not be invoked.

Exceptions
SAXException:
The application may raise an exception.
endElementback to summary
public void endElement(String uri, String localName, String qName) throws SAXException

Overrides org.dom4j.io.SAXContentHandler.endElement.

Implements org.xml.sax.ContentHandler.endElement.

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

Receive notification of the end of an element.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each element (such as finalising a tree node or writing output to a file).

Parameters
uri:String

The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.

localName:String

The local name (without prefix), or the empty string if Namespace processing is not being performed.

qName:String

The qualified name (with prefix), or the empty string if qualified names are not available.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
endEntityback to summary
public void endEntity(String name) throws SAXException

Overrides org.dom4j.io.SAXContentHandler.endEntity.

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.
endPrefixMappingback to summary
public void endPrefixMapping(String prefix) throws SAXException

Overrides org.dom4j.io.SAXContentHandler.endPrefixMapping.

Implements org.xml.sax.ContentHandler.endPrefixMapping.

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

Receive notification of the end of a Namespace mapping.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each prefix mapping.

Parameters
prefix:String

The Namespace prefix being declared.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
getXMLWriterback to summary
protected XMLWriter getXMLWriter()
ignorableWhitespaceback to summary
public void ignorableWhitespace(char[] parm1, int parm2, int parm3) throws SAXException

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

Implements org.xml.sax.ContentHandler.ignorableWhitespace.

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

Receive notification of ignorable whitespace in element content.

By default, do nothing. Application writers may override this method to take specific actions for each chunk of ignorable whitespace (such as adding data to a node or buffer, or printing it to a file).

Parameters
parm1:char[]

The whitespace characters.

parm2:int

The start position in the character array.

parm3:int

The number of characters to use from the character array.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
notationDeclback to summary
public void notationDecl(String name, String publicId, String systemId) throws SAXException

Overrides org.dom4j.io.SAXContentHandler.notationDecl.

Implements org.xml.sax.DTDHandler.notationDecl.

Doc from org.dom4j.io.SAXContentHandler.notationDecl.

Receive notification of a notation declaration event.

It is up to the application to record the notation for later reference, if necessary.

At least one of publicId and systemId must be non-null. If a system identifier is present, and it is a URL, the SAX parser must resolve it fully before passing it to the application through this event.

There is no guarantee that the notation declaration will be reported before any unparsed entities that use it.

Parameters
name:String

The notation name.

publicId:String

The notation's public identifier, or null if none was given.

systemId:String

The notation's system identifier, or null if none was given.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
processingInstructionback to summary
public void processingInstruction(String target, String data) throws SAXException

Overrides org.dom4j.io.SAXContentHandler.processingInstruction.

Implements org.xml.sax.ContentHandler.processingInstruction.

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

Receive notification of a processing instruction.

By default, do nothing. Application writers may override this method in a subclass to take specific actions for each processing instruction, such as setting status variables or invoking other methods.

Parameters
target:String

The processing instruction target.

data:String

The processing instruction data, or null if none is supplied.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
setDocumentLocatorback to summary
public void setDocumentLocator(Locator locator)

Overrides org.dom4j.io.SAXContentHandler.setDocumentLocator.

Implements org.xml.sax.ContentHandler.setDocumentLocator.

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

Receive a Locator object for document events.

By default, do nothing. Application writers may override this method in a subclass if they wish to store the locator for use with other document events.

Parameters
locator:Locator

A locator for all SAX document events.

setXMLWriterback to summary
public void setXMLWriter(XMLWriter writer)
skippedEntityback to summary
public void skippedEntity(String name) throws SAXException

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

Implements org.xml.sax.ContentHandler.skippedEntity.

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

Receive notification of a skipped entity.

By default, do nothing. Application writers may override this method in a subclass to take specific actions for each processing instruction, such as setting status variables or invoking other methods.

Parameters
name:String

The name of the skipped entity.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
startCDATAback to summary
public void startCDATA() throws SAXException

Overrides org.dom4j.io.SAXContentHandler.startCDATA.

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

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

Report the start of a CDATA section.

The contents of the CDATA section will be reported through the regular characters event; this event is intended only to report the boundary.

Exceptions
SAXException:
The application may raise an exception.
startDocumentback to summary
public void startDocument() throws SAXException

Overrides org.dom4j.io.SAXContentHandler.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).

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
startDTDback to summary
public void startDTD(String name, String publicId, String systemId) throws SAXException

Overrides org.dom4j.io.SAXContentHandler.startDTD.

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

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

Report the start of DTD declarations, if any.

This method is intended to report the beginning of the DOCTYPE declaration; if the document has no DOCTYPE declaration, this method will not be invoked.

All declarations reported through DTDHandler or DeclHandler events must appear between the startDTD and endDTD events. Declarations are assumed to belong to the internal DTD subset unless they appear between startEntity and endEntity events. Comments and processing instructions from the DTD should also be reported between the startDTD and endDTD events, in their original order of (logical) occurrence; they are not required to appear in their correct locations relative to DTDHandler or DeclHandler events, however.

Note that the start/endDTD events will appear within the start/endDocument events from ContentHandler and before the first startElement event.

Parameters
name:String

The document type name.

publicId:String

The declared public identifier for the external DTD subset, or null if none was declared.

systemId:String

The declared system identifier for the external DTD subset, or null if none was declared. (Note that this is not resolved against the document base URI.)

Exceptions
SAXException:
The application may raise an exception.
startElementback to summary
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException

Overrides org.dom4j.io.SAXContentHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

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

Receive notification of the start of an element.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).

Parameters
uri:String

The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.

localName:String

The local name (without prefix), or the empty string if Namespace processing is not being performed.

qName:String

The qualified name (with prefix), or the empty string if qualified names are not available.

atts:Attributes

The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
startEntityback to summary
public void startEntity(String name) throws SAXException

Overrides org.dom4j.io.SAXContentHandler.startEntity.

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.dom4j.io.SAXContentHandler.startPrefixMapping.

Implements org.xml.sax.ContentHandler.startPrefixMapping.

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

Receive notification of the start of a Namespace mapping.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each Namespace prefix scope (such as storing the prefix mapping).

Parameters
prefix:String

The Namespace prefix being declared.

uri:String

The Namespace URI mapped to the prefix.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
unparsedEntityDeclback to summary
public void unparsedEntityDecl(String name, String publicId, String systemId, String notation) throws SAXException

Overrides org.dom4j.io.SAXContentHandler.unparsedEntityDecl.

Implements org.xml.sax.DTDHandler.unparsedEntityDecl.

Doc from org.dom4j.io.SAXContentHandler.unparsedEntityDecl.

Receive notification of an unparsed entity declaration event.

Note that the notation name corresponds to a notation reported by the notationDeclevent. It is up to the application to record the entity for later reference, if necessary.

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

Parameters
name:String

The unparsed entity's name.

publicId:String

The entity's public identifier, or null if none was given.

systemId:String

The entity's system identifier.

notation:String

The name of the associated notation.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.