|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.lotus.xsl.xml4j2tx.HTMLFormatPrintVisitor
HTMLFormatPrintVisitor 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/>
.Formatted printing is defined as:
The following sample code uses the HTMLPrintVisitor on a hierarchy of nodes:
PrintWriter printWriter = new PrintWriter(); Visitor htmlPrintVisitor = new HTMLFormatPrintVisitor(printWriter); TreeTraversal treeTraversal = new NonRecursivePreorderTreeTraversal(htmlPrintVisitor); treeTraversal.traverse(document); printWriter.close();
By default, this doesn't print non-specified attributes.
Field Summary | |
int |
indent
|
java.lang.String |
m_attrSpecialChars
|
Constructor Summary | |
HTMLFormatPrintVisitor(java.io.Writer writer)
Constructor for default encoding. |
|
HTMLFormatPrintVisitor(java.io.Writer writer,
java.lang.String encoding)
Constructor for customized encoding. |
|
HTMLFormatPrintVisitor(java.io.Writer writer,
java.lang.String encoding,
java.lang.String doctype)
Constructor for customized encoding and doctype. |
|
HTMLFormatPrintVisitor(java.io.Writer writer,
java.lang.String encoding,
java.lang.String doctype,
int indent)
Constructor for customized encoding and doctype. |
Method Summary | |
void |
visitAttDefPre(com.ibm.xml.parser.AttDef attDef)
Ignore AttDef Nodes. |
void |
visitAttlistPre(com.ibm.xml.parser.Attlist attlist)
Ignore Attlist Nodes. |
void |
visitAttributePre(com.ibm.xml.parser.TXAttribute attribute)
Creates a formatted string representation of the specified attribute Node and its associated attributes, and directs it to the print writer. |
void |
visitCommentPre(com.ibm.xml.parser.TXComment comment)
Creates a formatted string representation of the specified comment Node in XML format, and directs it to the print writer. |
void |
visitDocumentPost(com.ibm.xml.parser.TXDocument document)
Flush the writer. |
void |
visitDocumentPre(com.ibm.xml.parser.TXDocument document)
Writes the doctype from the constructor (if any). |
void |
visitDTDPost(com.ibm.xml.parser.DTD dtd)
Ignore DTD Nodes. |
void |
visitDTDPre(com.ibm.xml.parser.DTD dtd)
Ignore DTD Nodes. |
void |
visitElementDeclPre(com.ibm.xml.parser.ElementDecl elementDecl)
Ignore ElementDecl Nodes. |
void |
visitElementPost(com.ibm.xml.parser.TXElement element)
Creates a formatted string representation of the end of the specified element Node, and directs it to the print writer. |
void |
visitElementPre(com.ibm.xml.parser.TXElement element)
Creates a formatted string representation of the start of the specified element Node and its associated attributes in XML format, and directs it to the print writer. |
void |
visitEntityDeclPre(com.ibm.xml.parser.EntityDecl entity)
Ignore Entity Nodes. |
void |
visitGeneralReferencePre(com.ibm.xml.parser.GeneralReference generalReference)
Ignore GeneralReference Nodes. |
void |
visitNotationPre(com.ibm.xml.parser.TXNotation notation)
Ignore TXNotation Nodes. |
void |
visitPIPre(com.ibm.xml.parser.TXPI pi)
Ignore TXPI Nodes. |
void |
visitTextPre(com.ibm.xml.parser.TXText text)
Creates a formatted string representation of the specified text Node, and directs it to the print writer. |
Field Detail |
public int indent
public java.lang.String m_attrSpecialChars
Constructor Detail |
public HTMLFormatPrintVisitor(java.io.Writer writer, java.lang.String encoding, java.lang.String doctype, int indent)
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.indent
- Number of spaces to indent at each nesting level.public HTMLFormatPrintVisitor(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 HTMLFormatPrintVisitor(java.io.Writer writer, java.lang.String encoding)
writer
- The character output stream to use.encoding
- Java character encoding in use by writer.public HTMLFormatPrintVisitor(java.io.Writer writer)
writer
- The character output stream to use.Method Detail |
public void visitDocumentPre(com.ibm.xml.parser.TXDocument document) throws java.lang.Exception
document
- Node print as HTML.public void visitDocumentPost(com.ibm.xml.parser.TXDocument document) throws java.lang.Exception
document
- Node to print as HTML.public void visitElementPre(com.ibm.xml.parser.TXElement element) throws java.lang.Exception
element
- Node to print with format.public void visitElementPost(com.ibm.xml.parser.TXElement element) throws java.lang.Exception
element
- Node to print as HTML.public void visitAttributePre(com.ibm.xml.parser.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.public void visitPIPre(com.ibm.xml.parser.TXPI pi) throws java.lang.Exception
pi
- CURRENTLY NOT IMPLEMENTED.public void visitTextPre(com.ibm.xml.parser.TXText text) throws java.lang.Exception
text
- Node to print with format.public void visitDTDPre(com.ibm.xml.parser.DTD dtd) throws java.lang.Exception
dtd
- CURRENTLY NOT IMPLEMENTED.public void visitDTDPost(com.ibm.xml.parser.DTD dtd) throws java.lang.Exception
dtd
- CURRENTLY NOT IMPLEMENTED.public void visitElementDeclPre(com.ibm.xml.parser.ElementDecl elementDecl) throws java.lang.Exception
elementDecl
- CURRENTLY NOT IMPLEMENTED.public void visitAttlistPre(com.ibm.xml.parser.Attlist attlist) throws java.lang.Exception
attlist
- CURRENTLY NOT IMPLEMENTED.public void visitAttDefPre(com.ibm.xml.parser.AttDef attDef) throws java.lang.Exception
attDef
- CURRENTLY NOT IMPLEMENTED.public void visitEntityDeclPre(com.ibm.xml.parser.EntityDecl entity) throws java.lang.Exception
entity
- CURRENTLY NOT IMPLEMENTED.public void visitNotationPre(com.ibm.xml.parser.TXNotation notation) throws java.lang.Exception
notation
- CURRENTLY NOT IMPLEMENTED.public void visitGeneralReferencePre(com.ibm.xml.parser.GeneralReference generalReference) throws java.lang.Exception
generalReference
- CURRENTLY NOT IMPLEMENTED.public void visitCommentPre(com.ibm.xml.parser.TXComment comment) throws java.lang.Exception
comment
- Node to print with format.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |