|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
org.apache.jackrabbit.commons.xml.DefaultContentHandler
org.apache.jackrabbit.commons.xml.SerializingContentHandler
public class SerializingContentHandler
A ContentHandler that serializes SAX events to a given
Result instance. The JAXP SAXTransformerFactory
facility is used for the serialization.
This class explicitly ensures that all namespace prefixes are also present as xmlns attributes in the serialized XML document. This avoids problems with Xalan's serialization behaviour which was (at least during JDK 1.4) to ignore namespaces if they were not present as xmlns attributes.
NOTE: The code in this class was originally written for Apache Cocoon and is included with some modifications here in Apache Jackrabbit. See the org.apache.cocoon.serialization.AbstractTextSerializer class in the cocoon-pipeline-impl component for the original code.
| Field Summary | |
|---|---|
static java.lang.String |
ENCODING
The character encoding used for serialization (UTF-8). |
| Method Summary | |
|---|---|
void |
endDocument()
Delegated to DefaultContentHandler.handler. |
void |
endElement(java.lang.String eltUri,
java.lang.String eltLocalName,
java.lang.String eltQName)
Receive notification of the end of an element. |
void |
endPrefixMapping(java.lang.String prefix)
End the scope of a prefix-URI mapping: remove entry from mapping tables. |
static org.xml.sax.helpers.DefaultHandler |
getSerializer(java.io.OutputStream output)
Creates a serializing content handler that writes to the given stream. |
static org.xml.sax.helpers.DefaultHandler |
getSerializer(javax.xml.transform.Result result)
Creates a serializing content handler that writes to the given result. |
static org.xml.sax.helpers.DefaultHandler |
getSerializer(java.io.Writer writer)
Creates a serializing content handler that writes to the given writer. |
void |
startDocument()
Delegated to DefaultContentHandler.handler. |
void |
startElement(java.lang.String eltUri,
java.lang.String eltLocalName,
java.lang.String eltQName,
org.xml.sax.Attributes attrs)
Ensure all namespace declarations are present as xmlns: attributes
and add those needed before calling superclass. |
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
Track mappings to be able to add xmlns: attributes
in startElement(). |
| Methods inherited from class org.apache.jackrabbit.commons.xml.DefaultContentHandler |
|---|
characters, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity |
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
|---|
error, fatalError, notationDecl, resolveEntity, unparsedEntityDecl, warning |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String ENCODING
https://issues.apache.org/jira/browse/JCR-1621,
Constant Field Values| Method Detail |
|---|
public static org.xml.sax.helpers.DefaultHandler getSerializer(java.io.OutputStream output)
throws org.xml.sax.SAXException
stream - serialization target
org.xml.sax.SAXException - if the content handler could not be initialized
public static org.xml.sax.helpers.DefaultHandler getSerializer(java.io.Writer writer)
throws org.xml.sax.SAXException
writer - serialization target
org.xml.sax.SAXException - if the content handler could not be initialized
public static org.xml.sax.helpers.DefaultHandler getSerializer(javax.xml.transform.Result result)
throws org.xml.sax.SAXException
result - serialization target
org.xml.sax.SAXException - if the content handler could not be initialized
public void startDocument()
throws org.xml.sax.SAXException
DefaultContentHandlerDefaultContentHandler.handler.
startDocument in interface org.xml.sax.ContentHandlerstartDocument in class DefaultContentHandlerorg.xml.sax.SAXException - if an error occurs
public void startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
throws org.xml.sax.SAXException
xmlns: attributes
in startElement().
startPrefixMapping in interface org.xml.sax.ContentHandlerstartPrefixMapping in class DefaultContentHandlerprefix - passed throughuri - passed through
org.xml.sax.SAXException - if an error occurs
public void startElement(java.lang.String eltUri,
java.lang.String eltLocalName,
java.lang.String eltQName,
org.xml.sax.Attributes attrs)
throws org.xml.sax.SAXException
xmlns: attributes
and add those needed before calling superclass. This is a workaround for a Xalan bug
(at least in version 2.0.1) : org.apache.xalan.serialize.SerializerToXML
ignores start/endPrefixMapping().
startElement in interface org.xml.sax.ContentHandlerstartElement in class DefaultContentHandlereltUri - passed througheltLocalName - passed througheltQName - passed throughattrs - passed through
org.xml.sax.SAXException - if an error occurs
public void endElement(java.lang.String eltUri,
java.lang.String eltLocalName,
java.lang.String eltQName)
throws org.xml.sax.SAXException
endElement in interface org.xml.sax.ContentHandlerendElement in class DefaultContentHandlereltUri - passed througheltLocalName - passed througheltQName - passed through
org.xml.sax.SAXException - if an error occurs
public void endPrefixMapping(java.lang.String prefix)
throws org.xml.sax.SAXException
endPrefixMapping in interface org.xml.sax.ContentHandlerendPrefixMapping in class DefaultContentHandlerprefix - passed through
org.xml.sax.SAXException - if an error occurs
public void endDocument()
throws org.xml.sax.SAXException
DefaultContentHandlerDefaultContentHandler.handler.
endDocument in interface org.xml.sax.ContentHandlerendDocument in class DefaultContentHandlerorg.xml.sax.SAXException - if an error occurs
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||