Fix bug on empty html body

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115920 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
dion 2004-08-01 12:34:22 +00:00
parent e8a2253fe8
commit c768d40496
2 changed files with 18 additions and 15 deletions

View File

@ -34,8 +34,8 @@ import org.dom4j.Node;
* A simple bean for converting a HTML document into an XDoc compliant XML
* document.
* This could be done via XSLT but is a little more complex than it might first
* appear so its done via Java code instead.
*
* appear so its done via Java code instead.
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
*/
public class Html2XdocBean {
@ -75,7 +75,7 @@ public class Html2XdocBean {
/**
* Converts the given HTML document into the corresponding XDoc format
* of XML
*
*
* @param html the input html document
* @return Document
*/
@ -100,9 +100,9 @@ public class Html2XdocBean {
/**
* Iterates thorugh the given body looking for h1, h2, h3 nodes and
* creating the associated section elements. Any text nodes
* creating the associated section elements. Any text nodes
* contained inside the body are wrapped in a &lt;p&gt; element
*
*
* @param output the output destination
* @param body the block of HTML markup to convert
*/
@ -140,10 +140,10 @@ public class Html2XdocBean {
/**
* Specifies whether the node is a text modifying construct that should be
* passed as is to the resultant html. Such as an anchor '&lt;a&gt;'.
*
*
* @param node the node to check
* @return true if the node is used to modify the formatting of the
* text; otherwise, false
* text; otherwise, false
*/
protected boolean isTextFormatting(Node node) {
// Ultimately this needs bold, italic, and so on
@ -151,9 +151,9 @@ public class Html2XdocBean {
}
/**
* Specifies whether the node is character data and should be passed as
* Specifies whether the node is character data and should be passed as
* straight text to the resultant html.
*
*
* @param node the node to check
* @return true if the node is a text node; otherwise, false.
*/
@ -164,7 +164,7 @@ public class Html2XdocBean {
/**
* Specifies whether the node is a heading node.
*
*
* @param node the node to check
* @return true if the given node is a heading element
* (h1, h2, h3 etc); otherwise, false
@ -176,7 +176,7 @@ public class Html2XdocBean {
/**
* Determines the heading level of the node.
*
*
* @param node the node to check
* @return the integer level of the heading
*/
@ -192,7 +192,7 @@ public class Html2XdocBean {
/**
* Creates a section or subsection as necessary based on the node
* for the output document.
*
*
* @param output the output document to attach the section
* @param node the node to base making a section on
*/
@ -233,7 +233,7 @@ public class Html2XdocBean {
* Determines if a new section is needed which is based on whether
* the node's a heading level and equal to or less than the current
* section's heading level.
*
*
* @param node the node to check
* @return true if the current node's information means for a new
* section; otherwise, false
@ -314,7 +314,7 @@ public class Html2XdocBean {
* @return List
*/
protected List getBodyContent(List content) {
// lets turn <pre> into <source> and concatenate consective entries
// lets turn <pre> into <source> and concatenate consective entries
Element lastPre = null;
LinkedList list = new LinkedList();
boolean lastWasElement = true;
@ -342,6 +342,8 @@ public class Html2XdocBean {
}
}
if (list.size() == 0) return list;
// now lets remove any whitespace text nodes at the beginning and end
while (true) {
Node node = (Node) list.getFirst();
@ -376,7 +378,7 @@ public class Html2XdocBean {
/**
* @param node the node to check
* @return true if the given node is a whitespace text node
* @return true if the given node is a whitespace text node
*/
protected boolean isWhitespace(Node node) {
if (node instanceof CharacterData) {

View File

@ -25,6 +25,7 @@
</properties>
<body>
<release version="1.3.1-SNAPSHOT" date="in CVS">
<action dev="dion" type="fix">Fix crash with an empty html body element.</action>
</release>
<release version="1.3" date="2004-05-15">
<action dev="dion" type="fix">Fix issues with DOM classes and jdk1.3</action>