freemind.main
Class XHTMLWriter

java.lang.Object
  extended by javax.swing.text.AbstractWriter
      extended by javax.swing.text.html.HTMLWriter
          extended by freemind.main.FixedHTMLWriter
              extended by freemind.main.XHTMLWriter

public class XHTMLWriter
extends FixedHTMLWriter

Create a new XHTMLWriter which is able to save a HTMLDocument as XHTML.

The result will be a valid XML file, but it is not granted that the file will really be XHTML 1.0 transitional conformous. The basic purpose of this class is to give an XSL processor access to plain HTML files.

Author:
Richard "Shred" K�rber

Nested Class Summary
static class XHTMLWriter.XHTMLFilterWriter
          This FilterWriter will convert the output of Swing's HTMLWriter to XHTML format.
 
Field Summary
 
Fields inherited from class javax.swing.text.AbstractWriter
NEWLINE
 
Constructor Summary
XHTMLWriter(java.io.Writer writer, javax.swing.text.html.HTMLDocument doc)
          Create a new XHTMLWriter that will write the entire HTMLDocument.
XHTMLWriter(java.io.Writer writer, javax.swing.text.html.HTMLDocument doc, int pos, int len)
          Create a new XHTMLWriter that will write a part of a HTMLDocument.
 
Method Summary
static void html2xhtml(java.io.Reader reader, java.io.Writer writer)
          Read HTML from the Reader, and send XHTML to the writer.
static void main(java.lang.String[] args)
          External call to convert a source HTML file to a target XHTML file.
 void write()
          Start the writing process.
protected  void writeLineSeparator()
           
protected  void writeOption(javax.swing.text.html.Option option)
           
 
Methods inherited from class freemind.main.FixedHTMLWriter
writeAttributes
 
Methods inherited from class javax.swing.text.html.HTMLWriter
closeOutUnwantedEmbeddedTags, comment, emptyTag, endTag, isBlockTag, matchNameAttribute, output, selectContent, startTag, synthesizedElement, text, textAreaContent, writeEmbeddedTags
 
Methods inherited from class javax.swing.text.AbstractWriter
decrIndent, getCanWrapLines, getCurrentLineLength, getDocument, getElementIterator, getEndOffset, getIndentLevel, getIndentSpace, getLineLength, getLineSeparator, getStartOffset, getText, getWriter, incrIndent, indent, inRange, isLineEmpty, setCanWrapLines, setCurrentLineLength, setIndentSpace, setLineLength, setLineSeparator, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XHTMLWriter

public XHTMLWriter(java.io.Writer writer,
                   javax.swing.text.html.HTMLDocument doc)
Create a new XHTMLWriter that will write the entire HTMLDocument.

Parameters:
writer - Writer to write to
doc - Source document

XHTMLWriter

public XHTMLWriter(java.io.Writer writer,
                   javax.swing.text.html.HTMLDocument doc,
                   int pos,
                   int len)
Create a new XHTMLWriter that will write a part of a HTMLDocument.

Parameters:
writer - Writer to write to
doc - Source document
pos - Starting position
len - Length
Method Detail

write

public void write()
           throws java.io.IOException,
                  javax.swing.text.BadLocationException
Start the writing process. An XML and DOCTYPE header will be written prior to the XHTML output.

Overrides:
write in class javax.swing.text.html.HTMLWriter
Throws:
java.io.IOException
javax.swing.text.BadLocationException

writeOption

protected void writeOption(javax.swing.text.html.Option option)
                    throws java.io.IOException
Overrides:
writeOption in class javax.swing.text.html.HTMLWriter
Throws:
java.io.IOException

writeLineSeparator

protected void writeLineSeparator()
                           throws java.io.IOException
Overrides:
writeLineSeparator in class javax.swing.text.html.HTMLWriter
Throws:
java.io.IOException

html2xhtml

public static void html2xhtml(java.io.Reader reader,
                              java.io.Writer writer)
                       throws java.io.IOException,
                              javax.swing.text.BadLocationException
Read HTML from the Reader, and send XHTML to the writer. Common mistakes in the HTML code will also be corrected. The result is pretty-printed.

Parameters:
reader - HTML source
writer - XHTML target
Throws:
java.io.IOException
javax.swing.text.BadLocationException

main

public static void main(java.lang.String[] args)
External call to convert a source HTML file to a target XHTML file.

Usage: java XHTMLWriter <source file> <target file>

Parameters:
args - Shell arguments