|
|
@ -26,25 +26,21 @@ import org.dom4j.Node; |
|
|
|
import org.xml.sax.SAXException; |
|
|
|
import org.xml.sax.SAXException; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <p> |
|
|
|
|
|
|
|
* <code>HTMLWriter</code> takes a DOM4J tree and formats it to a stream as |
|
|
|
* <code>HTMLWriter</code> takes a DOM4J tree and formats it to a stream as |
|
|
|
* HTML. This formatter is similar to XMLWriter but it outputs the text of CDATA |
|
|
|
* HTML. This formatter is similar to XMLWriter but it outputs the text of CDATA |
|
|
|
* and Entity sections rather than the serialised format as in XML, it has an |
|
|
|
* and Entity sections rather than the serialised format as in XML, it has an |
|
|
|
* XHTML mode, it retains whitespace in certain elements such as <PRE>, |
|
|
|
* XHTML mode, it retains whitespace in certain elements such as <PRE>, |
|
|
|
* and it supports certain elements which have no corresponding close tag such |
|
|
|
* and it supports certain elements which have no corresponding close tag such |
|
|
|
* as for <BR> and <P>. |
|
|
|
* as for <BR> and <P>. |
|
|
|
* </p> |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* <p> |
|
|
|
|
|
|
|
* The OutputFormat passed in to the constructor is checked for isXHTML() and |
|
|
|
* The OutputFormat passed in to the constructor is checked for isXHTML() and |
|
|
|
* isExpandEmptyElements(). See {@link OutputFormat OutputFormat}for details. |
|
|
|
* isExpandEmptyElements(). See {@link OutputFormat OutputFormat}for details. |
|
|
|
* Here are the rules for <b>this class </b> based on an OutputFormat, "format", |
|
|
|
* Here are the rules for <b>this class </b> based on an OutputFormat, "format", |
|
|
|
* passed in to the constructor: <br/><br/> |
|
|
|
* passed in to the constructor: |
|
|
|
* |
|
|
|
* |
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
* <li>If an element is in {@link #getOmitElementCloseSet() |
|
|
|
* <li>If an element is in {@link #getOmitElementCloseSet() |
|
|
|
* getOmitElementCloseSet}, then it is treated specially: |
|
|
|
* getOmitElementCloseSet}, then it is treated specially: |
|
|
|
* |
|
|
|
|
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
* <li>It never expands, since some browsers treat this as two separate |
|
|
|
* <li>It never expands, since some browsers treat this as two separate |
|
|
|
* Horizontal Rules: <HR></HR></li> |
|
|
|
* Horizontal Rules: <HR></HR></li> |
|
|
@ -54,7 +50,6 @@ import org.xml.sax.SAXException; |
|
|
|
* "/", but that's better than when it refuses to recognize this: <hr/> |
|
|
|
* "/", but that's better than when it refuses to recognize this: <hr/> |
|
|
|
* which it thinks is an element named "HR/".</li> |
|
|
|
* which it thinks is an element named "HR/".</li> |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
|
|
|
|
* </li> |
|
|
|
* </li> |
|
|
|
* <li>If {@link org.dom4j.io.OutputFormat#isXHTML() format.isXHTML()}, all |
|
|
|
* <li>If {@link org.dom4j.io.OutputFormat#isXHTML() format.isXHTML()}, all |
|
|
|
* elements must have either a close element, or be a closed single tag.</li> |
|
|
|
* elements must have either a close element, or be a closed single tag.</li> |
|
|
@ -62,41 +57,21 @@ import org.xml.sax.SAXException; |
|
|
|
* format.isExpandEmptyElements()}() is true, all elements are expanded except |
|
|
|
* format.isExpandEmptyElements()}() is true, all elements are expanded except |
|
|
|
* as above.</li> |
|
|
|
* as above.</li> |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
|
|
|
|
* <b>Examples </b> |
|
|
|
* <b>Examples </b> |
|
|
|
* </p> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p> |
|
|
|
|
|
|
|
* </p> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p> |
|
|
|
|
|
|
|
* If isXHTML == true, CDATA sections look like this: |
|
|
|
* If isXHTML == true, CDATA sections look like this: |
|
|
|
* |
|
|
|
* <pre> |
|
|
|
* <PRE> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <b><myelement><![CDATA[My data]]></myelement> </b> |
|
|
|
* <b><myelement><![CDATA[My data]]></myelement> </b> |
|
|
|
* |
|
|
|
* </pre> |
|
|
|
* </PRE> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* Otherwise, they look like this: |
|
|
|
* Otherwise, they look like this: |
|
|
|
* |
|
|
|
* <pre> |
|
|
|
* <PRE> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <b><myelement>My data</myelement> </b> |
|
|
|
* <b><myelement>My data</myelement> </b> |
|
|
|
* |
|
|
|
* </pre> |
|
|
|
* </PRE> |
|
|
|
|
|
|
|
* |
|
|
|
* Basically, {@link OutputFormat#isXHTML()} == |
|
|
|
* </p> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p> |
|
|
|
|
|
|
|
* Basically, {@link OutputFormat.isXHTML() OutputFormat.isXHTML()} == |
|
|
|
|
|
|
|
* <code>true</code> will produce valid XML, while {@link |
|
|
|
* <code>true</code> will produce valid XML, while {@link |
|
|
|
* org.dom4j.io.OutputFormat#isExpandEmptyElements() |
|
|
|
* OutputFormat#isExpandEmptyElements()} determines whether empty elements are |
|
|
|
* format.isExpandEmptyElements()} determines whether empty elements are |
|
|
|
|
|
|
|
* expanded if isXHTML is true, excepting the special HTML single tags. |
|
|
|
* expanded if isXHTML is true, excepting the special HTML single tags. |
|
|
|
* </p> |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* <p> |
|
|
|
|
|
|
|
* Also, HTMLWriter handles tags whose contents should be preformatted, that is, |
|
|
|
* Also, HTMLWriter handles tags whose contents should be preformatted, that is, |
|
|
|
* whitespace-preserved. By default, this set includes the tags <PRE>, |
|
|
|
* whitespace-preserved. By default, this set includes the tags <PRE>, |
|
|
|
* <SCRIPT>, <STYLE>, and <TEXTAREA>, case insensitively. It |
|
|
|
* <SCRIPT>, <STYLE>, and <TEXTAREA>, case insensitively. It |
|
|
@ -107,28 +82,14 @@ import org.xml.sax.SAXException; |
|
|
|
* However, the parser you use may store comments with linefeed-only text nodes |
|
|
|
* However, the parser you use may store comments with linefeed-only text nodes |
|
|
|
* (\n) even if your platform uses another line.separator character, and |
|
|
|
* (\n) even if your platform uses another line.separator character, and |
|
|
|
* HTMLWriter outputs Comment nodes exactly as the DOM is set up by the parser. |
|
|
|
* HTMLWriter outputs Comment nodes exactly as the DOM is set up by the parser. |
|
|
|
* See examples and discussion here: {@link#setPreformattedTags(java.util.Set) |
|
|
|
* See examples and discussion here: {@link #setPreformattedTags(java.util.Set)} |
|
|
|
* setPreformattedTags} |
|
|
|
|
|
|
|
* </p> |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* <p> |
|
|
|
|
|
|
|
* <b>Examples </b> |
|
|
|
* <b>Examples </b> |
|
|
|
* </p> |
|
|
|
|
|
|
|
* <blockquote> |
|
|
|
|
|
|
|
* <p> |
|
|
|
|
|
|
|
* <b>Pretty Printing </b> |
|
|
|
* <b>Pretty Printing </b> |
|
|
|
* </p> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p> |
|
|
|
|
|
|
|
* This example shows how to pretty print a string containing a valid HTML |
|
|
|
* This example shows how to pretty print a string containing a valid HTML |
|
|
|
* document to a string. You can also just call the static methods of this |
|
|
|
* document to a string. You can also just call the static methods of this |
|
|
|
* class: <br> |
|
|
|
* class: {@link #prettyPrintHTML(String)}or {@link #prettyPrintHTML(String,boolean,boolean,boolean,boolean)} |
|
|
|
* {@link #prettyPrintHTML(String) prettyPrintHTML(String)}or <br> |
|
|
|
* or {@link #prettyPrintXHTML(String)} for XHTML (note the X) |
|
|
|
* {@link #prettyPrintHTML(String,boolean,boolean,boolean,boolean) |
|
|
|
|
|
|
|
* prettyPrintHTML(String,boolean,boolean,boolean,boolean)} or, <br> |
|
|
|
|
|
|
|
* {@link #prettyPrintXHTML(String) prettyPrintXHTML(String)}for XHTML (note |
|
|
|
|
|
|
|
* the X) |
|
|
|
|
|
|
|
* </p> |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* <pre> |
|
|
|
* <pre> |
|
|
|
* String testPrettyPrint(String html) { |
|
|
|
* String testPrettyPrint(String html) { |
|
|
@ -147,12 +108,10 @@ import org.xml.sax.SAXException; |
|
|
|
* } |
|
|
|
* } |
|
|
|
* </pre> |
|
|
|
* </pre> |
|
|
|
* |
|
|
|
* |
|
|
|
* <p> |
|
|
|
|
|
|
|
* This example shows how to create a "squeezed" document, but one that will |
|
|
|
* This example shows how to create a "squeezed" document, but one that will |
|
|
|
* work in browsers even if the browser line length is limited. No newlines are |
|
|
|
* work in browsers even if the browser line length is limited. No newlines are |
|
|
|
* included, no extra whitespace at all, except where it it required by |
|
|
|
* included, no extra whitespace at all, except where it it required by |
|
|
|
* {@link #setPreformattedTags(java.util.Set) setPreformattedTags}. |
|
|
|
* {@link #setPreformattedTags(java.util.Set) setPreformattedTags}. |
|
|
|
* </p> |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* <pre> |
|
|
|
* <pre> |
|
|
|
* String testCrunch(String html) { |
|
|
|
* String testCrunch(String html) { |
|
|
@ -172,21 +131,19 @@ import org.xml.sax.SAXException; |
|
|
|
* } |
|
|
|
* } |
|
|
|
* </pre> |
|
|
|
* </pre> |
|
|
|
* |
|
|
|
* |
|
|
|
* </blockquote> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @author <a href="mailto:james.strachan@metastuff.com">James Strachan </a> |
|
|
|
* @author <a href="mailto:james.strachan@metastuff.com">James Strachan </a> |
|
|
|
* @author Laramie Crocker |
|
|
|
* @author Laramie Crocker |
|
|
|
* @version $Revision$ |
|
|
|
* @version $Revision: 1.21 $ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class HTMLWriter extends XMLWriter { |
|
|
|
public class HTMLWriter extends XMLWriter { |
|
|
|
private static String lineSeparator = System.getProperty("line.separator"); |
|
|
|
private static String lineSeparator = System.getProperty("line.separator"); |
|
|
|
|
|
|
|
|
|
|
|
protected static final HashSet DEFAULT_PREFORMATTED_TAGS; |
|
|
|
protected static final HashSet<String> DEFAULT_PREFORMATTED_TAGS; |
|
|
|
|
|
|
|
|
|
|
|
static { |
|
|
|
static { |
|
|
|
// If you change this list, update the javadoc examples, above in the
|
|
|
|
// If you change this list, update the javadoc examples, above in the
|
|
|
|
// class javadoc, in writeElement, and in setPreformattedTags().
|
|
|
|
// class javadoc, in writeElement, and in setPreformattedTags().
|
|
|
|
DEFAULT_PREFORMATTED_TAGS = new HashSet(); |
|
|
|
DEFAULT_PREFORMATTED_TAGS = new HashSet<String>(); |
|
|
|
DEFAULT_PREFORMATTED_TAGS.add("PRE"); |
|
|
|
DEFAULT_PREFORMATTED_TAGS.add("PRE"); |
|
|
|
DEFAULT_PREFORMATTED_TAGS.add("SCRIPT"); |
|
|
|
DEFAULT_PREFORMATTED_TAGS.add("SCRIPT"); |
|
|
|
DEFAULT_PREFORMATTED_TAGS.add("STYLE"); |
|
|
|
DEFAULT_PREFORMATTED_TAGS.add("STYLE"); |
|
|
@ -201,7 +158,7 @@ public class HTMLWriter extends XMLWriter { |
|
|
|
DEFAULT_HTML_FORMAT.setSuppressDeclaration(true); |
|
|
|
DEFAULT_HTML_FORMAT.setSuppressDeclaration(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Stack formatStack = new Stack(); |
|
|
|
private Stack<FormatState> formatStack = new Stack<FormatState>(); |
|
|
|
|
|
|
|
|
|
|
|
private String lastText = ""; |
|
|
|
private String lastText = ""; |
|
|
|
|
|
|
|
|
|
|
@ -210,13 +167,13 @@ public class HTMLWriter extends XMLWriter { |
|
|
|
// legal values are 0+, but -1 signifies lazy initialization.
|
|
|
|
// legal values are 0+, but -1 signifies lazy initialization.
|
|
|
|
private int newLineAfterNTags = -1; |
|
|
|
private int newLineAfterNTags = -1; |
|
|
|
|
|
|
|
|
|
|
|
private HashSet preformattedTags = DEFAULT_PREFORMATTED_TAGS; |
|
|
|
private HashSet<String> preformattedTags = DEFAULT_PREFORMATTED_TAGS; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Used to store the qualified element names which should have no close |
|
|
|
* Used to store the qualified element names which should have no close |
|
|
|
* element tag |
|
|
|
* element tag |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private HashSet omitElementCloseSet; |
|
|
|
private HashSet<String> omitElementCloseSet; |
|
|
|
|
|
|
|
|
|
|
|
public HTMLWriter(Writer writer) { |
|
|
|
public HTMLWriter(Writer writer) { |
|
|
|
super(writer, DEFAULT_HTML_FORMAT); |
|
|
|
super(writer, DEFAULT_HTML_FORMAT); |
|
|
@ -349,9 +306,9 @@ public class HTMLWriter extends XMLWriter { |
|
|
|
qualifiedName.toUpperCase()); |
|
|
|
qualifiedName.toUpperCase()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private HashSet internalGetOmitElementCloseSet() { |
|
|
|
private HashSet<String> internalGetOmitElementCloseSet() { |
|
|
|
if (omitElementCloseSet == null) { |
|
|
|
if (omitElementCloseSet == null) { |
|
|
|
omitElementCloseSet = new HashSet(); |
|
|
|
omitElementCloseSet = new HashSet<String>(); |
|
|
|
loadOmitElementCloseSet(omitElementCloseSet); |
|
|
|
loadOmitElementCloseSet(omitElementCloseSet); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -359,7 +316,7 @@ public class HTMLWriter extends XMLWriter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// If you change this, change the javadoc for getOmitElementCloseSet.
|
|
|
|
// If you change this, change the javadoc for getOmitElementCloseSet.
|
|
|
|
protected void loadOmitElementCloseSet(Set set) { |
|
|
|
protected void loadOmitElementCloseSet(Set<String> set) { |
|
|
|
set.add("AREA"); |
|
|
|
set.add("AREA"); |
|
|
|
set.add("BASE"); |
|
|
|
set.add("BASE"); |
|
|
|
set.add("BR"); |
|
|
|
set.add("BR"); |
|
|
@ -382,8 +339,8 @@ public class HTMLWriter extends XMLWriter { |
|
|
|
* |
|
|
|
* |
|
|
|
* @return A clone of the Set. |
|
|
|
* @return A clone of the Set. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Set getOmitElementCloseSet() { |
|
|
|
public Set<String> getOmitElementCloseSet() { |
|
|
|
return (Set) (internalGetOmitElementCloseSet().clone()); |
|
|
|
return (Set<String>) (internalGetOmitElementCloseSet().clone()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -402,21 +359,17 @@ public class HTMLWriter extends XMLWriter { |
|
|
|
* @param newSet |
|
|
|
* @param newSet |
|
|
|
* DOCUMENT ME! |
|
|
|
* DOCUMENT ME! |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setOmitElementCloseSet(Set newSet) { |
|
|
|
public void setOmitElementCloseSet(Set<String> newSet) { |
|
|
|
// resets, and safely empties it out if newSet is null.
|
|
|
|
// resets, and safely empties it out if newSet is null.
|
|
|
|
omitElementCloseSet = new HashSet(); |
|
|
|
omitElementCloseSet = new HashSet<String>(); |
|
|
|
|
|
|
|
|
|
|
|
if (newSet != null) { |
|
|
|
if (newSet != null) { |
|
|
|
omitElementCloseSet = new HashSet(); |
|
|
|
omitElementCloseSet = new HashSet<String>(); |
|
|
|
|
|
|
|
|
|
|
|
Object aTag; |
|
|
|
for (String aTag : newSet) { |
|
|
|
Iterator iter = newSet.iterator(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (iter.hasNext()) { |
|
|
|
|
|
|
|
aTag = iter.next(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (aTag != null) { |
|
|
|
if (aTag != null) { |
|
|
|
omitElementCloseSet.add(aTag.toString().toUpperCase()); |
|
|
|
omitElementCloseSet.add(aTag.toUpperCase()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -424,22 +377,18 @@ public class HTMLWriter extends XMLWriter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @see #setPreformattedTags(java.util.Set) setPreformattedTags |
|
|
|
* @see #setPreformattedTags(java.util.Set) setPreformattedTags |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return DOCUMENT ME! |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Set getPreformattedTags() { |
|
|
|
public Set<String> getPreformattedTags() { |
|
|
|
return (Set) (preformattedTags.clone()); |
|
|
|
return (Set<String>) (preformattedTags.clone()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <p> |
|
|
|
|
|
|
|
* Override the default set, which includes PRE, SCRIPT, STYLE, and |
|
|
|
* Override the default set, which includes PRE, SCRIPT, STYLE, and |
|
|
|
* TEXTAREA, case insensitively. |
|
|
|
* TEXTAREA, case insensitively. |
|
|
|
* </p> |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* <p> |
|
|
|
|
|
|
|
* <b>Setting Preformatted Tags </b> |
|
|
|
* <b>Setting Preformatted Tags </b> |
|
|
|
* </p> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p> |
|
|
|
|
|
|
|
* Pass in a Set of Strings, one for each tag name that should be treated |
|
|
|
* Pass in a Set of Strings, one for each tag name that should be treated |
|
|
|
* like a PRE tag. You may pass in null or an empty Set to assign the empty |
|
|
|
* like a PRE tag. You may pass in null or an empty Set to assign the empty |
|
|
|
* set, in which case no tags will be treated as preformatted, except that |
|
|
|
* set, in which case no tags will be treated as preformatted, except that |
|
|
@ -448,9 +397,7 @@ public class HTMLWriter extends XMLWriter { |
|
|
|
* preserved, including whitespace on the same line preceding the close tag. |
|
|
|
* preserved, including whitespace on the same line preceding the close tag. |
|
|
|
* This will generally make the close tag not line up with the start tag, |
|
|
|
* This will generally make the close tag not line up with the start tag, |
|
|
|
* but it preserves the intention of the whitespace within the tag. |
|
|
|
* but it preserves the intention of the whitespace within the tag. |
|
|
|
* </p> |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* <p> |
|
|
|
|
|
|
|
* The browser considers leading whitespace before the close tag to be |
|
|
|
* The browser considers leading whitespace before the close tag to be |
|
|
|
* significant, but leading whitespace before the open tag to be |
|
|
|
* significant, but leading whitespace before the open tag to be |
|
|
|
* insignificant. For example, if the HTML author doesn't put the close |
|
|
|
* insignificant. For example, if the HTML author doesn't put the close |
|
|
@ -459,13 +406,8 @@ public class HTMLWriter extends XMLWriter { |
|
|
|
* the HTML author's intent. Similarly, in a PRE, the browser treats a |
|
|
|
* the HTML author's intent. Similarly, in a PRE, the browser treats a |
|
|
|
* flushed left close PRE tag as different from a close tag with leading |
|
|
|
* flushed left close PRE tag as different from a close tag with leading |
|
|
|
* whitespace. Again, this must be left up to the HTML author. |
|
|
|
* whitespace. Again, this must be left up to the HTML author. |
|
|
|
* </p> |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* <p> |
|
|
|
|
|
|
|
* <b>Examples </b> |
|
|
|
* <b>Examples </b> |
|
|
|
* </p> |
|
|
|
|
|
|
|
* <blockquote> |
|
|
|
|
|
|
|
* <p> |
|
|
|
|
|
|
|
* Here is an example of how you can set the PreformattedTags list using |
|
|
|
* Here is an example of how you can set the PreformattedTags list using |
|
|
|
* setPreformattedTags to include IFRAME, as well as the default set, if you |
|
|
|
* setPreformattedTags to include IFRAME, as well as the default set, if you |
|
|
|
* have an instance of this class named myHTMLWriter: |
|
|
|
* have an instance of this class named myHTMLWriter: |
|
|
@ -520,28 +462,20 @@ public class HTMLWriter extends XMLWriter { |
|
|
|
* |
|
|
|
* |
|
|
|
* </pre> |
|
|
|
* </pre> |
|
|
|
* |
|
|
|
* |
|
|
|
* </p> |
|
|
|
|
|
|
|
* </blockquote> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param newSet |
|
|
|
* @param newSet |
|
|
|
* DOCUMENT ME! |
|
|
|
* DOCUMENT ME! |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setPreformattedTags(Set newSet) { |
|
|
|
public void setPreformattedTags(Set<String> newSet) { |
|
|
|
// no fancy merging, just set it, assuming they did a
|
|
|
|
// no fancy merging, just set it, assuming they did a
|
|
|
|
// getExcludeTrimTags() first if they wanted to preserve the default
|
|
|
|
// getExcludeTrimTags() first if they wanted to preserve the default
|
|
|
|
// set.
|
|
|
|
// set.
|
|
|
|
// resets, and safely empties it out if newSet is null.
|
|
|
|
// resets, and safely empties it out if newSet is null.
|
|
|
|
preformattedTags = new HashSet(); |
|
|
|
preformattedTags = new HashSet<String>(); |
|
|
|
|
|
|
|
|
|
|
|
if (newSet != null) { |
|
|
|
if (newSet != null) { |
|
|
|
Object aTag; |
|
|
|
for (String aTag : newSet) { |
|
|
|
Iterator iter = newSet.iterator(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (iter.hasNext()) { |
|
|
|
|
|
|
|
aTag = iter.next(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (aTag != null) { |
|
|
|
if (aTag != null) { |
|
|
|
preformattedTags.add(aTag.toString().toUpperCase()); |
|
|
|
preformattedTags.add(aTag.toUpperCase()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -687,9 +621,9 @@ public class HTMLWriter extends XMLWriter { |
|
|
|
* close tags off of the default omitElementCloseSet set. Use one of |
|
|
|
* close tags off of the default omitElementCloseSet set. Use one of |
|
|
|
* the write methods if you want stream output. |
|
|
|
* the write methods if you want stream output. |
|
|
|
* |
|
|
|
* |
|
|
|
* @throws java.io.IOException |
|
|
|
* @throws java.io.IOException DOCUMENT ME! |
|
|
|
* @throws java.io.UnsupportedEncodingException |
|
|
|
* @throws java.io.UnsupportedEncodingException DOCUMENT ME! |
|
|
|
* @throws org.dom4j.DocumentException |
|
|
|
* @throws org.dom4j.DocumentException DOCUMENT ME! |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static String prettyPrintHTML(String html) |
|
|
|
public static String prettyPrintHTML(String html) |
|
|
|
throws java.io.IOException, java.io.UnsupportedEncodingException, |
|
|
|
throws java.io.IOException, java.io.UnsupportedEncodingException, |
|
|
@ -709,9 +643,9 @@ public class HTMLWriter extends XMLWriter { |
|
|
|
* converted to XHTML empty tags: <HR/> Use one of the write |
|
|
|
* converted to XHTML empty tags: <HR/> Use one of the write |
|
|
|
* methods if you want stream output. |
|
|
|
* methods if you want stream output. |
|
|
|
* |
|
|
|
* |
|
|
|
* @throws java.io.IOException |
|
|
|
* @throws java.io.IOException DOCUMENT ME! |
|
|
|
* @throws java.io.UnsupportedEncodingException |
|
|
|
* @throws java.io.UnsupportedEncodingException DOCUMENT ME! |
|
|
|
* @throws org.dom4j.DocumentException |
|
|
|
* @throws org.dom4j.DocumentException DOCUMENT ME! |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static String prettyPrintXHTML(String html) |
|
|
|
public static String prettyPrintXHTML(String html) |
|
|
|
throws java.io.IOException, java.io.UnsupportedEncodingException, |
|
|
|
throws java.io.IOException, java.io.UnsupportedEncodingException, |
|
|
@ -739,9 +673,9 @@ public class HTMLWriter extends XMLWriter { |
|
|
|
* override allows you to specify various formatter options. Use one |
|
|
|
* override allows you to specify various formatter options. Use one |
|
|
|
* of the write methods if you want stream output. |
|
|
|
* of the write methods if you want stream output. |
|
|
|
* |
|
|
|
* |
|
|
|
* @throws java.io.IOException |
|
|
|
* @throws java.io.IOException DOCUMENT ME! |
|
|
|
* @throws java.io.UnsupportedEncodingException |
|
|
|
* @throws java.io.UnsupportedEncodingException DOCUMENT ME! |
|
|
|
* @throws org.dom4j.DocumentException |
|
|
|
* @throws org.dom4j.DocumentException DOCUMENT ME! |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static String prettyPrintHTML(String html, boolean newlines, |
|
|
|
public static String prettyPrintHTML(String html, boolean newlines, |
|
|
|
boolean trim, boolean isXHTML, boolean expandEmpty) |
|
|
|
boolean trim, boolean isXHTML, boolean expandEmpty) |
|
|
|