|
XML for Java Compatibility API 2.0.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.xml.parser.NOOPVisitor | +--com.ibm.xml.parser.ToXMLStringVisitor | +--com.ibm.xml.parser.util.HTMLPrintVisitor
HTMLPrintVisitor implements the Visitor interface in the visitor design pattern for the purpose of printing in HTML-like format the various DOM- and XML4J-defined Nodes.
In HTML-like printing, only the following Nodes are printed:
<BR>
instead of <BR/>
.The following sample code uses the HTMLPrintVisitor on a hierarchy of nodes:
PrintWriter printWriter = new PrintWriter(); Visitor htmlPrintVisitor = new HTMLPrintVisitor(printWriter); TreeTraversal treeTraversal = new NonRecursivePreorderTreeTraversal(htmlPrintVisitor); treeTraversal.traverse(document); printWriter.close();
By default, this doesn't print non-specified attributes.
Visitor
,
TreeTraversal
,
NonRecursivePreorderTreeTraversal
,
ToXMLStringVisitor
,
FormatPrintVisitor
Field Summary | |
protected java.lang.String |
doctype
|
protected int |
level
|
Fields inherited from class com.ibm.xml.parser.ToXMLStringVisitor |
encoding,
isPrintNonSpecifiedAttributes,
writer |
Constructor Summary | |
HTMLPrintVisitor(java.io.Writer writer)
Constructor for default encoding. |
|
HTMLPrintVisitor(java.io.Writer writer,
java.lang.String encoding)
Constructor for customized encoding. |
|
HTMLPrintVisitor(java.io.Writer writer,
java.lang.String encoding,
java.lang.String doctype)
Constructor for customized encoding and doctype. |
Method Summary | |
void |
visitAttDefPre(AttDef attDef)
Ignore AttDef Nodes. |
void |
visitAttlistPre(Attlist attlist)
Ignore Attlist Nodes. |
void |
visitAttributePre(TXAttribute attribute)
Creates a formatted string representation of the specified attribute Node and its associated attributes, and directs it to the print writer. |
void |
visitDocumentPost(TXDocument document)
Flush the writer. |
void |
visitDocumentPre(TXDocument document)
Writes the doctype from the constructor (if any). |
void |
visitDTDPost(DTD dtd)
Ignore DTD Nodes. |
void |
visitDTDPre(DTD dtd)
Ignore DTD Nodes. |
void |
visitElementDeclPre(ElementDecl elementDecl)
Ignore ElementDecl Nodes. |
void |
visitElementPost(TXElement element)
Creates a formatted string representation of the end of the specified element Node, and directs it to the print writer. |
void |
visitElementPre(TXElement element)
Creates a formatted string representation of the start of the specified element Node and its associated attributes, and directs it to the print writer. |
void |
visitEntityDeclPre(EntityDecl entity)
Ignore Entity Nodes. |
void |
visitGeneralReferencePre(GeneralReference generalReference)
Ignore GeneralReference Nodes. |
void |
visitNotationPre(TXNotation notation)
Ignore TXNotation Nodes. |
void |
visitPIPre(TXPI pi)
Ignore TXPI Nodes. |
void |
visitTextPre(TXText text)
Creates a formatted string representation of the specified text Node, and directs it to the print writer. |
Methods inherited from class com.ibm.xml.parser.ToXMLStringVisitor |
getPrintNonSpecifiedAttributes,
setPrintNonSpecifiedAttributes,
visitCommentPre,
visitPseudoNodePre |
Methods inherited from class com.ibm.xml.parser.NOOPVisitor |
visitAttDefPost,
visitAttlistPost,
visitAttributePost,
visitCommentPost,
visitDocumentFragmentPost,
visitDocumentFragmentPre,
visitElementDeclPost,
visitEntityDeclPost,
visitGeneralReferencePost,
visitNotationPost,
visitPIPost,
visitPseudoNodePost,
visitTextPost |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected int level
protected java.lang.String doctype
Constructor Detail |
public HTMLPrintVisitor(java.io.Writer writer, java.lang.String encoding, java.lang.String doctype)
writer
- The character output stream to use.encoding
- Java character encoding in use by writer.doctype
- String to be printed at the top of the document.public HTMLPrintVisitor(java.io.Writer writer, java.lang.String encoding)
writer
- The character output stream to use.encoding
- Java character encoding in use by writer.public HTMLPrintVisitor(java.io.Writer writer)
writer
- The character output stream to use.Method Detail |
public void visitDocumentPre(TXDocument document) throws java.lang.Exception
document
- Node print as HTML.TXDocument
public void visitDocumentPost(TXDocument document) throws java.lang.Exception
document
- Node to print as HTML.TXDocument
public void visitElementPre(TXElement element) throws java.lang.Exception
element
- Node to print as HTML.TXElement
public void visitElementPost(TXElement element) throws java.lang.Exception
element
- Node to print as HTML.TXElement
public void visitAttributePre(TXAttribute attribute) throws java.lang.Exception
Note that TXAttribute Nodes are not parsed into the document object hierarchy by the XML4J parser; attributes exist as part of a TXElement Node.
element
- Node to print as HTML.TXElement
public void visitPIPre(TXPI pi) throws java.lang.Exception
pi
- CURRENTLY NOT IMPLEMENTED.TXPI
public void visitTextPre(TXText text) throws java.lang.Exception
text
- Node to print with format.TXText
public void visitDTDPre(DTD dtd) throws java.lang.Exception
dtd
- CURRENTLY NOT IMPLEMENTED.DTD
public void visitDTDPost(DTD dtd) throws java.lang.Exception
dtd
- CURRENTLY NOT IMPLEMENTED.DTD
public void visitElementDeclPre(ElementDecl elementDecl) throws java.lang.Exception
elementDecl
- CURRENTLY NOT IMPLEMENTED.ElementDecl
public void visitAttlistPre(Attlist attlist) throws java.lang.Exception
attlist
- CURRENTLY NOT IMPLEMENTED.Attlist
public void visitAttDefPre(AttDef attDef) throws java.lang.Exception
attDef
- CURRENTLY NOT IMPLEMENTED.AttDef
public void visitEntityDeclPre(EntityDecl entity) throws java.lang.Exception
entity
- CURRENTLY NOT IMPLEMENTED.EntityDecl
public void visitNotationPre(TXNotation notation) throws java.lang.Exception
notation
- CURRENTLY NOT IMPLEMENTED.TXNotation
public void visitGeneralReferencePre(GeneralReference generalReference) throws java.lang.Exception
generalReference
- CURRENTLY NOT IMPLEMENTED.GeneralReference
|
XML for Java Compatibility API 2.0.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |