Class AbstractSAXOutputProcessor
- java.lang.Object
-
- org.jdom2.output.support.AbstractOutputProcessor
-
- org.jdom2.output.support.AbstractSAXOutputProcessor
-
- All Implemented Interfaces:
SAXOutputProcessor
public class AbstractSAXOutputProcessor extends AbstractOutputProcessor implements SAXOutputProcessor
Outputs a JDOM document as a stream of SAX2 events.Most ContentHandler callbacks are supported. Neither
ignorableWhitespace()norskippedEntity()have been implemented.At this time, it is not possible to access notations and unparsed entity references in a DTD from JDOM. Therefore, full
DTDHandlercall-backs have not been implemented yet.The
The SAX2 API does not support whitespace formatting outside the root element. As a consequence any Formatting options that would normally affect the structures outside the root element will be ignored.ErrorHandlercall-backs have not been implemented, since these are supposed to be invoked when the document is parsed and at this point the document exists in memory and is known to have no errors.- Author:
- Brett McLaughlin, Jason Hunter, Fred Trimble, Bradley S. Huffman, Rolf Lear
-
-
Constructor Summary
Constructors Constructor Description AbstractSAXOutputProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.xml.sax.XMLReadercreateParser()Creates a SAX XMLReader.protected voidprintCDATA(SAXTarget out, FormatStack fstack, CDATA cdata)This will handle printing of aCDATA.protected voidprintComment(SAXTarget out, FormatStack fstack, Comment comment)This will handle printing of aComment.protected voidprintContent(SAXTarget out, FormatStack fstack, NamespaceStack nstack, Walker walker)This will handle printing of a List ofContent.protected voidprintDocType(SAXTarget out, FormatStack fstack, DocType docType)This will handle printing of aDocType.protected voidprintDocument(SAXTarget out, FormatStack fstack, NamespaceStack nstack, Document document)This will handle printing of aDocument.protected voidprintElement(SAXTarget out, FormatStack fstack, NamespaceStack nstack, Element element)This will handle printing of anElement.protected voidprintEntityRef(SAXTarget out, FormatStack fstack, EntityRef entity)This will handle printing of anEntityRef.protected voidprintProcessingInstruction(SAXTarget out, FormatStack fstack, ProcessingInstruction pi)This will handle printing of aProcessingInstruction.protected voidprintText(SAXTarget out, FormatStack fstack, Text text)This will handle printing of aText.voidprocess(SAXTarget out, Format format, java.util.List<? extends Content> list)This will handle printing out a list of nodes.voidprocess(SAXTarget out, Format format, CDATA cdata)Print out anode.CDATAvoidprocess(SAXTarget out, Format format, Comment comment)Print out a.Commentvoidprocess(SAXTarget out, Format format, DocType doctype)Print out the.DocTypevoidprocess(SAXTarget out, Format format, Document doc)This will print theto the given SAXTarget.Documentvoidprocess(SAXTarget out, Format format, Element element)voidprocess(SAXTarget out, Format format, EntityRef entity)Print out a.EntityRefvoidprocess(SAXTarget out, Format format, ProcessingInstruction pi)Print out a.ProcessingInstructionvoidprocess(SAXTarget out, Format format, Text text)Print out anode.TextvoidprocessAsDocument(SAXTarget out, Format format, java.util.List<? extends Content> nodes)This will handle printing out a list of nodes thats encapsulated in start/end Document SAX events.voidprocessAsDocument(SAXTarget out, Format format, Element node)-
Methods inherited from class org.jdom2.output.support.AbstractOutputProcessor
buildWalker
-
-
-
-
Method Detail
-
process
public void process(SAXTarget out, Format format, Document doc) throws JDOMException
Description copied from interface:SAXOutputProcessorThis will print theto the given SAXTarget.DocumentWarning: using your own SAXTarget may cause the outputter's preferred character encoding to be ignored. If you use encodings other than UTF-8, we recommend using the method that takes an OutputStream instead.
- Specified by:
processin interfaceSAXOutputProcessor- Parameters:
out-SAXTargetto use.format-Formatinstance specifying output styledoc-Documentto format.- Throws:
JDOMException- if there is an issue encountered during output.
-
process
public void process(SAXTarget out, Format format, DocType doctype) throws JDOMException
Description copied from interface:SAXOutputProcessorPrint out the.DocType- Specified by:
processin interfaceSAXOutputProcessor- Parameters:
out-SAXTargetto use.format-Formatinstance specifying output styledoctype-DocTypeto output.- Throws:
JDOMException- if there is an issue encountered during output.
-
process
public void process(SAXTarget out, Format format, Element element) throws JDOMException
Description copied from interface:SAXOutputProcessor- Specified by:
processin interfaceSAXOutputProcessor- Parameters:
out-SAXTargetto use.format-Formatinstance specifying output styleelement-Elementto output.- Throws:
JDOMException- if there is an issue encountered during output.
-
process
public void process(SAXTarget out, Format format, java.util.List<? extends Content> list) throws JDOMException
Description copied from interface:SAXOutputProcessorThis will handle printing out a list of nodes. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".- Specified by:
processin interfaceSAXOutputProcessor- Parameters:
out-SAXTargetto use.format-Formatinstance specifying output stylelist-Listof nodes.- Throws:
JDOMException- if there is an issue encountered during output.
-
process
public void process(SAXTarget out, Format format, CDATA cdata) throws JDOMException
Description copied from interface:SAXOutputProcessorPrint out anode.CDATA- Specified by:
processin interfaceSAXOutputProcessor- Parameters:
out-SAXTargetto use.format-Formatinstance specifying output stylecdata-CDATAto output.- Throws:
JDOMException- if there is an issue encountered during output.
-
process
public void process(SAXTarget out, Format format, Text text) throws JDOMException
Description copied from interface:SAXOutputProcessorPrint out anode. Perfoms the necessary entity escaping and whitespace stripping.Text- Specified by:
processin interfaceSAXOutputProcessor- Parameters:
out-SAXTargetto use.format-Formatinstance specifying output styletext-Textto output.- Throws:
JDOMException- if there is an issue encountered during output.
-
process
public void process(SAXTarget out, Format format, Comment comment) throws JDOMException
Description copied from interface:SAXOutputProcessorPrint out a.Comment- Specified by:
processin interfaceSAXOutputProcessor- Parameters:
out-SAXTargetto use.format-Formatinstance specifying output stylecomment-Commentto output.- Throws:
JDOMException- if there is an issue encountered during output.
-
process
public void process(SAXTarget out, Format format, ProcessingInstruction pi) throws JDOMException
Description copied from interface:SAXOutputProcessorPrint out a.ProcessingInstruction- Specified by:
processin interfaceSAXOutputProcessor- Parameters:
out-SAXTargetto use.format-Formatinstance specifying output stylepi-ProcessingInstructionto output.- Throws:
JDOMException- if there is an issue encountered during output.
-
process
public void process(SAXTarget out, Format format, EntityRef entity) throws JDOMException
Description copied from interface:SAXOutputProcessorPrint out a.EntityRef- Specified by:
processin interfaceSAXOutputProcessor- Parameters:
out-SAXTargetto use.format-Formatinstance specifying output styleentity-EntityRefto output.- Throws:
JDOMException- if there is an issue encountered during output.
-
processAsDocument
public void processAsDocument(SAXTarget out, Format format, java.util.List<? extends Content> nodes) throws JDOMException
Description copied from interface:SAXOutputProcessorThis will handle printing out a list of nodes thats encapsulated in start/end Document SAX events. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".- Specified by:
processAsDocumentin interfaceSAXOutputProcessor- Parameters:
out-SAXTargetto use.format-Formatinstance specifying output stylenodes-Listof nodes.- Throws:
JDOMException- if there is an issue encountered during output.
-
processAsDocument
public void processAsDocument(SAXTarget out, Format format, Element node) throws JDOMException
Description copied from interface:SAXOutputProcessorPrint out anencapsulated in start/end Document SAX events, including itsElements, and all contained (child) elements, etc.Attribute- Specified by:
processAsDocumentin interfaceSAXOutputProcessor- Parameters:
out-SAXTargetto use.format-Formatinstance specifying output stylenode-Elementto output.- Throws:
JDOMException- if there is an issue encountered during output.
-
printDocument
protected void printDocument(SAXTarget out, FormatStack fstack, NamespaceStack nstack, Document document) throws org.xml.sax.SAXException
This will handle printing of aDocument.- Parameters:
out-SAXTargetto use.fstack- the FormatStacknstack- the NamespaceStackdocument-Documentto write.- Throws:
org.xml.sax.SAXException- if the destination SAXTarget fails
-
printDocType
protected void printDocType(SAXTarget out, FormatStack fstack, DocType docType) throws org.xml.sax.SAXException
This will handle printing of aDocType.- Parameters:
out-SAXTargetto use.fstack- the FormatStackdocType-DocTypeto write.- Throws:
org.xml.sax.SAXException- if the destination SAXTarget fails
-
printProcessingInstruction
protected void printProcessingInstruction(SAXTarget out, FormatStack fstack, ProcessingInstruction pi) throws org.xml.sax.SAXException
This will handle printing of aProcessingInstruction.- Parameters:
out-SAXTargetto use.fstack- the FormatStackpi-ProcessingInstructionto write.- Throws:
org.xml.sax.SAXException- if the destination SAXTarget fails
-
printComment
protected void printComment(SAXTarget out, FormatStack fstack, Comment comment) throws org.xml.sax.SAXException
This will handle printing of aComment.- Parameters:
out-SAXTargetto use.fstack- the FormatStackcomment-Commentto write.- Throws:
org.xml.sax.SAXException- if the destination SAXTarget fails
-
printEntityRef
protected void printEntityRef(SAXTarget out, FormatStack fstack, EntityRef entity) throws org.xml.sax.SAXException
This will handle printing of anEntityRef.- Parameters:
out-SAXTargetto use.fstack- the FormatStackentity-EntotyRefto write.- Throws:
org.xml.sax.SAXException- if the destination SAXTarget fails
-
printCDATA
protected void printCDATA(SAXTarget out, FormatStack fstack, CDATA cdata) throws org.xml.sax.SAXException
This will handle printing of aCDATA.- Parameters:
out-SAXTargetto use.fstack- the FormatStackcdata-CDATAto write.- Throws:
org.xml.sax.SAXException- if the destination SAXTarget fails
-
printText
protected void printText(SAXTarget out, FormatStack fstack, Text text) throws org.xml.sax.SAXException
This will handle printing of aText.- Parameters:
out-SAXTargetto use.fstack- the FormatStacktext-Textto write.- Throws:
org.xml.sax.SAXException- if the destination SAXTarget fails
-
printElement
protected void printElement(SAXTarget out, FormatStack fstack, NamespaceStack nstack, Element element) throws org.xml.sax.SAXException
This will handle printing of anElement.This method arranges for outputting the Element infrastructure including Namespace Declarations and Attributes.
- Parameters:
out-SAXTargetto use.fstack- the FormatStacknstack- the NamespaceStackelement-Elementto write.- Throws:
org.xml.sax.SAXException- if the destination SAXTarget fails
-
printContent
protected void printContent(SAXTarget out, FormatStack fstack, NamespaceStack nstack, Walker walker) throws org.xml.sax.SAXException
This will handle printing of a List ofContent.It relies on the appropriate Walker to get the formatting right.
- Parameters:
out-SAXTargetto use.fstack- the FormatStacknstack- the NamespaceStackwalker-WakerofContentto write.- Throws:
org.xml.sax.SAXException- if the destination SAXTarget fails
-
createParser
protected org.xml.sax.XMLReader createParser() throws java.lang.ExceptionCreates a SAX XMLReader.
- Returns:
XMLReadera SAX2 parser.- Throws:
java.lang.Exception- if no parser can be created.
-
-