org.dom4j.io
Class SAXModifier
public class SAXModifier
extends java.lang.Object
The SAXModifier reads, modifies and writes XML documents using SAX.
Registered
ElementModifier
objects 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
XMLWriter
is specified.
- Wonne Keysers (Realsoftware.be)
SAXModifier() - Creates a new modifier.
|
SAXModifier(XMLReader xmlReader) - Creates a new modifier that will the specified
org.xml.sax.XMLReader to parse the source.
|
SAXModifier(XMLReader xmlReader, boolean pruneElements) - Creates a new modifier that will the specified
org.xml.sax.XMLReader to parse the source.
|
SAXModifier(boolean pruneElements) - Creates a new modifier.
|
SAXModifier
public SAXModifier()
Creates a new modifier.
The XMLReader to parse the source will be created via the
org.xml.sax.driver system property or JAXP if the system property is not
set.
SAXModifier
public SAXModifier(XMLReader xmlReader)
Creates a new modifier that will the specified org.xml.sax.XMLReader
to parse the source.
xmlReader
- The XMLReader to use
SAXModifier
public SAXModifier(XMLReader xmlReader,
boolean pruneElements)
Creates a new modifier that will the specified org.xml.sax.XMLReader
to parse the source.
xmlReader
- The XMLReader to usepruneElements
- Set to true when the modified document must NOT be kept in
memory.
SAXModifier
public SAXModifier(boolean pruneElements)
Creates a new modifier.
The XMLReader to parse the source will be created via the
org.xml.sax.driver system property or JAXP if the system property is not
set.
pruneElements
- Set to true when the modified document must NOT be kept in
memory.
addModifier
public void addModifier(String path,
ElementModifier modifier)
Adds the
ElementModifier
to be called when the specified element
path is encounted while parsing the source.
path
- The element path to be handledmodifier
- The ElementModifier
to be called by the event based
processor.
getDocumentFactory
public DocumentFactory getDocumentFactory()
DocumentFactory
that will be used
isPruneElements
public boolean isPruneElements()
Returns true when xml elements are not kept in memory while parsing. The
Document
returned by the modify methods will be null.
- Returns the pruneElements.
modify
public Document modify(File source)
throws DocumentException
Reads a Document from the given
java.io.File
and writes it to the
specified
XMLWriter
using SAX. Registered
objects are invoked on the fly.
source
- is the File
to read from.
- the newly created Document instance
DocumentException
- DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.
modify
public Document modify(InputSource source)
throws DocumentException
Reads a Document from the given
org.xml.sax.InputSource
and
writes it to the specified
XMLWriter
using SAX. Registered
ElementModifier
objects are invoked on the fly.
source
- is the org.xml.sax.InputSource
to read from.
- the newly created Document instance
DocumentException
- DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.
modify
public Document modify(InputStream source)
throws DocumentException
Reads a Document from the given
java.io.InputStream
and writes it
to the specified
XMLWriter
using SAX. Registered
ElementModifier
objects are invoked on the fly.
source
- is the java.io.InputStream
to read from.
- the newly created Document instance
DocumentException
- DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.
modify
public Document modify(InputStream source,
String systemId)
throws DocumentException
Reads a Document from the given
java.io.InputStream
and writes it
to the specified
XMLWriter
using SAX. Registered
ElementModifier
objects are invoked on the fly.
source
- is the java.io.InputStream
to read from.systemId
- DOCUMENT ME!
- the newly created Document instance
DocumentException
- DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.
modify
public Document modify(Reader source)
throws DocumentException
Reads a Document from the given
java.io.Reader
and writes it to
the specified
XMLWriter
using SAX. Registered
ElementModifier
objects are invoked on the fly.
source
- is the java.io.Reader
to read from.
- the newly created Document instance
DocumentException
- DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.
modify
public Document modify(Reader source,
String systemId)
throws DocumentException
Reads a Document from the given
java.io.Reader
and writes it to
the specified
XMLWriter
using SAX. Registered
ElementModifier
objects are invoked on the fly.
source
- is the java.io.Reader
to read from.systemId
- DOCUMENT ME!
- the newly created Document instance
DocumentException
- DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.
modify
public Document modify(String source)
throws DocumentException
Reads a Document from the given URL or filename and writes it to the
specified
XMLWriter
using SAX. Registered
objects are invoked on the fly.
source
- is the URL or filename to read from.
- the newly created Document instance
DocumentException
- DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.
modify
public Document modify(URL source)
throws DocumentException
Reads a Document from the given
java.net.URL
and writes it to the
specified
XMLWriter
using SAX. Registered
objects are invoked on the fly.
source
- is the java.net.URL
to read from.
- the newly created Document instance
DocumentException
- DocumentException org.dom4j.DocumentException} if an error
occurs during parsing.
removeModifier
public void removeModifier(String path)
Removes the
ElementModifier
from the event based processor, for
the specified element path.
resetModifiers
public void resetModifiers()
Removes all registered
ElementModifier
instances from the event
based processor.
setDocumentFactory
public void setDocumentFactory(DocumentFactory factory)
factory
- DocumentFactory
to be used
setXMLWriter
public void setXMLWriter(XMLWriter writer)
Sets the
XMLWriter
used to write the modified document.
writer
- The writer to use.
Copyright B) 2005 MetaStuff Ltd. All Rights Reserved. Hosted by 