public class SAXModifier
extends java.lang.Object
Registered ElementModifierobjects can provide modifications to (part
of) the xml tree, while the document is still being processed. This makes it
possible to change large xml documents without having them in memory.
The modified document is written when the XMLWriteris specified.
| Constructor and Description |
|---|
SAXModifier()
Creates a new modifier.
|
SAXModifier(boolean pruneElements)
Creates a new modifier.
|
SAXModifier(org.xml.sax.XMLReader xmlReader)
Creates a new modifier that will the specified
XMLReader to parse the source. |
SAXModifier(org.xml.sax.XMLReader xmlReader,
boolean pruneElements)
Creates a new modifier that will the specified
XMLReader to parse the source. |
| Modifier and Type | Method and Description |
|---|---|
void |
addModifier(java.lang.String path,
ElementModifier modifier)
Adds the
ElementModifierto be called when the specified element
path is encounted while parsing the source. |
DocumentFactory |
getDocumentFactory()
Get the
DocumentFactoryused to create the DOM4J
document structure |
XMLWriter |
getXMLWriter()
Returns the current
XMLWriter. |
boolean |
isPruneElements()
Returns true when xml elements are not kept in memory while parsing.
|
Document |
modify(java.io.File source)
Reads a Document from the given
Fileand writes it to the
specified XMLWriterusing SAX. |
Document |
modify(org.xml.sax.InputSource source)
Reads a Document from the given
InputSourceand
writes it to the specified XMLWriterusing SAX. |
Document |
modify(java.io.InputStream source)
Reads a Document from the given
InputStreamand writes it
to the specified XMLWriterusing SAX. |
Document |
modify(java.io.InputStream source,
java.lang.String systemId)
Reads a Document from the given
InputStreamand writes it
to the specified XMLWriterusing SAX. |
Document |
modify(java.io.Reader source)
Reads a Document from the given
Readerand writes it to
the specified XMLWriterusing SAX. |
Document |
modify(java.io.Reader source,
java.lang.String systemId)
Reads a Document from the given
Readerand writes it to
the specified XMLWriterusing SAX. |
Document |
modify(java.lang.String source)
Reads a Document from the given URL or filename and writes it to the
specified
XMLWriterusing SAX. |
Document |
modify(java.net.URL source)
Reads a Document from the given
URLand writes it to the
specified XMLWriterusing SAX. |
void |
removeModifier(java.lang.String path)
Removes the
ElementModifierfrom the event based processor, for
the specified element path. |
void |
resetModifiers()
Removes all registered
ElementModifierinstances from the event
based processor. |
void |
setDocumentFactory(DocumentFactory factory)
Sets the
DocumentFactoryused to create the DOM4J
document tree. |
void |
setXMLWriter(XMLWriter writer)
Sets the
XMLWriterused to write the modified document. |
public SAXModifier()
public SAXModifier(boolean pruneElements)
pruneElements - Set to true when the modified document must NOT be kept in
memory.public SAXModifier(org.xml.sax.XMLReader xmlReader)
XMLReader to parse the source.xmlReader - The XMLReader to usepublic SAXModifier(org.xml.sax.XMLReader xmlReader,
boolean pruneElements)
XMLReader to parse the source.xmlReader - The XMLReader to usepruneElements - Set to true when the modified document must NOT be kept in
memory.public Document modify(java.io.File source) throws DocumentException
Fileand writes it to the
specified XMLWriterusing SAX. Registered ElementModifier
objects are invoked on the fly.source - is the File to read from.DocumentException - DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.public Document modify(org.xml.sax.InputSource source) throws DocumentException
InputSourceand
writes it to the specified XMLWriterusing SAX. Registered
ElementModifierobjects are invoked on the fly.source - is the org.xml.sax.InputSource to read from.DocumentException - DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.public Document modify(java.io.InputStream source) throws DocumentException
InputStreamand writes it
to the specified XMLWriterusing SAX. Registered ElementModifier objects are invoked on the fly.source - is the java.io.InputStream to read from.DocumentException - DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.public Document modify(java.io.InputStream source, java.lang.String systemId) throws DocumentException
InputStreamand writes it
to the specified XMLWriterusing SAX. Registered ElementModifier objects are invoked on the fly.source - is the java.io.InputStream to read from.systemId - DOCUMENT ME!DocumentException - DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.public Document modify(java.io.Reader source) throws DocumentException
Readerand writes it to
the specified XMLWriterusing SAX. Registered ElementModifier objects are invoked on the fly.source - is the java.io.Reader to read from.DocumentException - DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.public Document modify(java.io.Reader source, java.lang.String systemId) throws DocumentException
Readerand writes it to
the specified XMLWriterusing SAX. Registered ElementModifier objects are invoked on the fly.source - is the java.io.Reader to read from.systemId - DOCUMENT ME!DocumentException - DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.public Document modify(java.net.URL source) throws DocumentException
URLand writes it to the
specified XMLWriterusing SAX. Registered ElementModifier
objects are invoked on the fly.source - is the java.net.URL to read from.DocumentException - DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.public Document modify(java.lang.String source) throws DocumentException
XMLWriterusing SAX. Registered ElementModifier
objects are invoked on the fly.source - is the URL or filename to read from.DocumentException - DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.public void addModifier(java.lang.String path,
ElementModifier modifier)
ElementModifierto be called when the specified element
path is encounted while parsing the source.path - The element path to be handledmodifier - The ElementModifierto be called by the event based
processor.public void resetModifiers()
ElementModifierinstances from the event
based processor.public void removeModifier(java.lang.String path)
ElementModifierfrom the event based processor, for
the specified element path.path - The path to remove the ElementModifierfor.public DocumentFactory getDocumentFactory()
DocumentFactoryused to create the DOM4J
document structureDocumentFactory that will be usedpublic void setDocumentFactory(DocumentFactory factory)
DocumentFactoryused to create the DOM4J
document tree.factory - DocumentFactory to be usedpublic void setXMLWriter(XMLWriter writer)
XMLWriterused to write the modified document.writer - The writer to use.public boolean isPruneElements()
Documentreturned by the modify methods will be null.