public abstract class AbstractXMLOutputProcessor extends AbstractOutputProcessor implements XMLOutputProcessor
XMLOutputProcessor
for supporting the XMLOutputter.
process*(...) methods are public because they match the
XMLOutputProcessor interface but the remaining methods are all protected.
People who want to create a custom XMLOutputProcessor for XMLOutputter are
able to extend this class and modify any functionality they want. Before
sub-classing this you should first check to see if the Format class
can get you the results you want.
Subclasses of this should have reentrant methods. This is
easiest to accomplish simply by not allowing any instance fields. If your
sub-class has an instance field/variable, then it's probably broken.
NamespaceStack and FormatStack that are
managed in the
printElement(Writer, FormatStack, NamespaceStack, Element) method.
The stacks are pushed and popped in that method only. They significantly
improve the performance and readability of the code.
The NamespaceStack is only sent through to the
printElement(Writer, FormatStack, NamespaceStack, Element) and
printContent(Writer, FormatStack, NamespaceStack, Walker) methods,
but the FormatStack is pushed through to all print* Methods.
Text, CDATA and EntityRef content. This will be
referred to as 'Text-like content'
XMLOutputter delegates the management and formatting of Content to a
Walker instance. See Walker and its various implementations for
details on how the Element content is processed.
Because the Walker interface specifies that Text/CDATA content may be
returned as either Text/CDATA instances or as formatted String values
this class sometimes uses printCDATA(...) and printText(...), and sometimes
uses the more direct textCDATA(Writer, String) or
textRaw(Writer, String) as
appropriate. In other words, subclasses should probably override these second
methods instead of the print methods.
write(...) methods. Thus, all other methods do their
respective processing and delegate the actual destination output to the
write(Writer, char) or write(Writer, String) methods.
All Text-like content (printCDATA, printText, and printEntityRef) will
ultimately be output through the the text* methods (and no other content).XMLOutputter,
XMLOutputProcessor| 构造器和说明 |
|---|
AbstractXMLOutputProcessor() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
process(java.io.Writer out,
Format format,
CDATA cdata)
Print out a
node. |
void |
process(java.io.Writer out,
Format format,
Comment comment)
Print out a
. |
void |
process(java.io.Writer out,
Format format,
DocType doctype)
Print out the
. |
void |
process(java.io.Writer out,
Format format,
Document doc)
This will print the
to the given Writer. |
void |
process(java.io.Writer out,
Format format,
Element element)
|
void |
process(java.io.Writer out,
Format format,
EntityRef entity)
Print out a
. |
void |
process(java.io.Writer out,
Format format,
java.util.List<? extends Content> list)
This will handle printing out a list of nodes.
|
void |
process(java.io.Writer out,
Format format,
ProcessingInstruction pi)
Print out a
. |
void |
process(java.io.Writer out,
Format format,
Text text)
Print out a
node. |
public void process(java.io.Writer out,
Format format,
Document doc)
throws java.io.IOException
XMLOutputProcessorDocument to the given Writer.
Warning: using your own Writer 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.
process 在接口中 XMLOutputProcessorout - Writer to use.format - Format instance specifying output styledoc - Document to format.java.io.IOException - if there's any problem writing.public void process(java.io.Writer out,
Format format,
DocType doctype)
throws java.io.IOException
XMLOutputProcessorDocType.process 在接口中 XMLOutputProcessorout - Writer to use.format - Format instance specifying output styledoctype - DocType to output.java.io.IOException - if there's any problem writing.public void process(java.io.Writer out,
Format format,
Element element)
throws java.io.IOException
XMLOutputProcessorprocess 在接口中 XMLOutputProcessorout - Writer to use.format - Format instance specifying output styleelement - Element to output.java.io.IOException - if there's any problem writing.public void process(java.io.Writer out,
Format format,
java.util.List<? extends Content> list)
throws java.io.IOException
XMLOutputProcessorprocess 在接口中 XMLOutputProcessorout - Writer to use.format - Format instance specifying output stylelist - List of nodes.java.io.IOException - if there's any problem writing.public void process(java.io.Writer out,
Format format,
CDATA cdata)
throws java.io.IOException
XMLOutputProcessorCDATA node.process 在接口中 XMLOutputProcessorout - Writer to use.format - Format instance specifying output stylecdata - CDATA to output.java.io.IOException - if there's any problem writing.public void process(java.io.Writer out,
Format format,
Text text)
throws java.io.IOException
XMLOutputProcessorText node. Perfoms the necessary entity
escaping and whitespace stripping.process 在接口中 XMLOutputProcessorout - Writer to use.format - Format instance specifying output styletext - Text to output.java.io.IOException - if there's any problem writing.public void process(java.io.Writer out,
Format format,
Comment comment)
throws java.io.IOException
XMLOutputProcessorComment.process 在接口中 XMLOutputProcessorout - Writer to use.format - Format instance specifying output stylecomment - Comment to output.java.io.IOException - if there's any problem writing.public void process(java.io.Writer out,
Format format,
ProcessingInstruction pi)
throws java.io.IOException
XMLOutputProcessorProcessingInstruction.process 在接口中 XMLOutputProcessorout - Writer to use.format - Format instance specifying output stylepi - ProcessingInstruction to output.java.io.IOException - if there's any problem writing.public void process(java.io.Writer out,
Format format,
EntityRef entity)
throws java.io.IOException
XMLOutputProcessorEntityRef.process 在接口中 XMLOutputProcessorout - Writer to use.format - Format instance specifying output styleentity - EntityRef to output.java.io.IOException - if there's any problem writing.