|
||||||||||
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 String |
ENCODING
The character encoding used for serialization (UTF-8). |
Method Summary | |
---|---|
void |
endDocument()
Delegated to DefaultContentHandler.handler . |
void |
endElement(String eltUri,
String eltLocalName,
String eltQName)
Receive notification of the end of an element. |
void |
endPrefixMapping(String prefix)
End the scope of a prefix-URI mapping: remove entry from mapping tables. |
static DefaultHandler |
getSerializer(OutputStream output)
Creates a serializing content handler that writes to the given stream. |
static DefaultHandler |
getSerializer(Result result)
Creates a serializing content handler that writes to the given result. |
static DefaultHandler |
getSerializer(Writer writer)
Creates a serializing content handler that writes to the given writer. |
void |
startDocument()
Delegated to DefaultContentHandler.handler . |
void |
startElement(String eltUri,
String eltLocalName,
String eltQName,
Attributes attrs)
Ensure all namespace declarations are present as xmlns: attributes
and add those needed before calling superclass. |
void |
startPrefixMapping(String prefix,
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 String ENCODING
https://issues.apache.org/jira/browse/JCR-1621
,
Constant Field ValuesMethod Detail |
---|
public static DefaultHandler getSerializer(OutputStream output) throws SAXException
stream
- serialization target
SAXException
- if the content handler could not be initializedpublic static DefaultHandler getSerializer(Writer writer) throws SAXException
writer
- serialization target
SAXException
- if the content handler could not be initializedpublic static DefaultHandler getSerializer(Result result) throws SAXException
result
- serialization target
SAXException
- if the content handler could not be initializedpublic void startDocument() throws SAXException
DefaultContentHandler
DefaultContentHandler.handler
.
startDocument
in interface ContentHandler
startDocument
in class DefaultContentHandler
SAXException
- if an error occurspublic void startPrefixMapping(String prefix, String uri) throws SAXException
xmlns:
attributes
in startElement()
.
startPrefixMapping
in interface ContentHandler
startPrefixMapping
in class DefaultContentHandler
prefix
- passed throughuri
- passed through
SAXException
- if an error occurspublic void startElement(String eltUri, String eltLocalName, String eltQName, Attributes attrs) throws 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 ContentHandler
startElement
in class DefaultContentHandler
eltUri
- passed througheltLocalName
- passed througheltQName
- passed throughattrs
- passed through
SAXException
- if an error occurspublic void endElement(String eltUri, String eltLocalName, String eltQName) throws SAXException
endElement
in interface ContentHandler
endElement
in class DefaultContentHandler
eltUri
- passed througheltLocalName
- passed througheltQName
- passed through
SAXException
- if an error occurspublic void endPrefixMapping(String prefix) throws SAXException
endPrefixMapping
in interface ContentHandler
endPrefixMapping
in class DefaultContentHandler
prefix
- passed through
SAXException
- if an error occurspublic void endDocument() throws SAXException
DefaultContentHandler
DefaultContentHandler.handler
.
endDocument
in interface ContentHandler
endDocument
in class DefaultContentHandler
SAXException
- if an error occurs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |