public class LagartoDOMBuilderTagVisitor extends java.lang.Object implements TagVisitor
In experimental html-plus mode we do have some further HTML5 rules implemented, that according to some rules may change the node position. However, not all rules are implemented (yet) and this is still just experimental.
Modifier and Type | Field and Description |
---|---|
protected LagartoDOMBuilder |
domBuilder |
protected boolean |
enabled
While enabled, nodes will be added to the DOM tree.
|
protected HtmlCCommentExpressionMatcher |
htmlCCommentExpressionMatcher |
protected HtmlVoidRules |
htmlVoidRules |
protected HtmlImplicitClosingRules |
implRules |
protected Node |
parentNode |
protected Document |
rootNode |
Constructor and Description |
---|
LagartoDOMBuilderTagVisitor(LagartoDOMBuilder domBuilder) |
Modifier and Type | Method and Description |
---|---|
void |
cdata(java.lang.CharSequence cdata)
Invoked on CDATA sequence.
|
void |
comment(java.lang.CharSequence comment)
Invoked on comment.
|
void |
condComment(java.lang.CharSequence expression,
boolean isStartingTag,
boolean isHidden,
boolean isHiddenEndTag)
Invoked on IE conditional comment.
|
protected Element |
createElementNode(Tag tag)
Creates new element with correct configuration.
|
void |
doctype(Doctype doctype)
Invoked on DOCTYPE directive.
|
void |
end()
Finishes the tree building.
|
void |
error(java.lang.String message)
Warn about parsing error.
|
protected Node |
findMatchingParentOpenTag(java.lang.String tagName)
Finds matching parent open tag or
null if not found. |
protected void |
fixUnclosedTagsUpToMatchingParent(Tag tag,
Node matchingParent)
Fixes all unclosed tags up to matching parent.
|
Document |
getDocument()
Returns root
document node of parsed DOM tree. |
protected void |
removeLastChildNodeIfEmptyText(Node parentNode,
boolean closedTag)
Removes last child node if contains just empty text.
|
void |
script(Tag tag,
java.lang.CharSequence body)
Invoked on script tag.
|
void |
start()
Starts with DOM building.
|
void |
tag(Tag tag)
Visits tags.
|
void |
text(java.lang.CharSequence text)
Invoked on text i.e. anything other than a tag.
|
void |
xml(java.lang.CharSequence version,
java.lang.CharSequence encoding,
java.lang.CharSequence standalone)
Invoked on xml declaration.
|
protected final LagartoDOMBuilder domBuilder
protected final HtmlImplicitClosingRules implRules
protected HtmlVoidRules htmlVoidRules
protected Document rootNode
protected Node parentNode
protected boolean enabled
protected HtmlCCommentExpressionMatcher htmlCCommentExpressionMatcher
public LagartoDOMBuilderTagVisitor(LagartoDOMBuilder domBuilder)
public void start()
Document
node.start
in interface TagVisitor
public void end()
end
in interface TagVisitor
protected Element createElementNode(Tag tag)
public void tag(Tag tag)
tag
in interface TagVisitor
protected void removeLastChildNodeIfEmptyText(Node parentNode, boolean closedTag)
protected Node findMatchingParentOpenTag(java.lang.String tagName)
null
if not found.protected void fixUnclosedTagsUpToMatchingParent(Tag tag, Node matchingParent)
Tags that can be closed implicitly are checked and closed.
There is optional check for detecting orphan tags inside the table or lists. If set, tags can be closed beyond the border of the table and the list and it is reported as orphan tag.
This is just a generic solutions, closest to the rules.
public void script(Tag tag, java.lang.CharSequence body)
TagVisitor
script
in interface TagVisitor
public void comment(java.lang.CharSequence comment)
TagVisitor
comment
in interface TagVisitor
public void text(java.lang.CharSequence text)
TagVisitor
text
in interface TagVisitor
public void cdata(java.lang.CharSequence cdata)
TagVisitor
cdata
in interface TagVisitor
public void xml(java.lang.CharSequence version, java.lang.CharSequence encoding, java.lang.CharSequence standalone)
TagVisitor
xml
in interface TagVisitor
public void doctype(Doctype doctype)
TagVisitor
doctype
in interface TagVisitor
public void condComment(java.lang.CharSequence expression, boolean isStartingTag, boolean isHidden, boolean isHiddenEndTag)
TagVisitor
The following conditional comments are recognized:
<!--[if IE 6]>one<![endif]-->
<!--[if IE 6]><!-->two<!---<![endif]-->
<!--[if IE 6]>three<!--xx<![endif]-->
<![if IE 6]>four<![endif]>
condComment
in interface TagVisitor
public void error(java.lang.String message)
TagVisitor
error
in interface TagVisitor
message
- parsing error messageCopyright © 2003-present Jodd Team