public class LagartoDOMBuilderTagVisitor extends java.lang.Object implements TagVisitor
| Modifier and Type | Field and Description |
|---|---|
protected LagartoDOMBuilder |
domBuilder |
protected boolean |
enabled
While enabled, nodes will be added to the DOM tree.
|
protected HtmlImplicitClosingRules |
implRules |
protected Node |
parentNode |
protected LagartoParserContext |
parserContext |
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,
java.lang.CharSequence comment)
Invoked on IE conditional comment.
|
protected CData |
createCData(java.lang.String cdata)
Creates
tag. |
protected Comment |
createComment(java.lang.String comment)
Creates
Comment. |
protected Comment |
createConditionalComment(java.lang.String comment,
boolean isStartingTag,
boolean conditionalDownlevelHidden,
java.lang.String additionalComment)
Creates conditional
Comment. |
protected Document |
createDocument()
Creates root
Document node. |
protected DocumentType |
createDocumentType(java.lang.String value,
java.lang.String publicId,
java.lang.String baseUri) |
protected Element |
createElement(java.lang.String name)
Creates empty tag.
|
protected Element |
createElement(java.lang.String tagName,
boolean voidElement,
boolean selfClosed)
Creates empty
Element node. |
protected Element |
createElement(Tag tag,
boolean voidElement,
boolean selfClosed)
|
protected Element |
createElementNode(Tag tag)
Creates new element with correct configuration.
|
protected Text |
createText(java.lang.String text)
Creates
Text node. |
protected XmlDeclaration |
createXmlDeclaration(Tag tag) |
void |
doctype(java.lang.String name,
java.lang.String publicId,
java.lang.String baseUri)
Invoked on DOCTYPE directive.
|
void |
end()
Invoked at the end, after all content is visited.
|
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(LagartoParserContext parserContext)
Invoked on very beginning of the visiting.
|
void |
style(Tag tag,
java.lang.CharSequence body)
Invoked on style tag.
|
void |
tag(Tag tag)
Invoked on
tag (open, close or empty). |
void |
text(java.lang.CharSequence text)
Invoked on text i.e. anything other than a tag.
|
void |
xml(Tag tag)
Invoked on xml declaration.
|
void |
xmp(Tag tag,
java.lang.CharSequence body)
Invoked on xmp tag.
|
protected final LagartoDOMBuilder domBuilder
protected final HtmlImplicitClosingRules implRules
protected Document rootNode
protected Node parentNode
protected boolean enabled
protected LagartoParserContext parserContext
public LagartoDOMBuilderTagVisitor(LagartoDOMBuilder domBuilder)
public void start(LagartoParserContext parserContext)
TagVisitorparser context that
gives some information during the parsing process.start in interface TagVisitorpublic void end()
TagVisitorend in interface TagVisitorprotected Element createElementNode(Tag tag)
public void tag(Tag tag)
TagVisitortag (open, close or empty).
Warning: the passed tag instance should not be kept beyond this method as the parser reuse it!
tag in interface TagVisitorprotected 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 xmp(Tag tag, java.lang.CharSequence body)
TagVisitorxmp in interface TagVisitorpublic void style(Tag tag, java.lang.CharSequence body)
TagVisitorstyle in interface TagVisitorpublic void script(Tag tag, java.lang.CharSequence body)
TagVisitorscript in interface TagVisitorpublic void comment(java.lang.CharSequence comment)
TagVisitorcomment in interface TagVisitorpublic void text(java.lang.CharSequence text)
TagVisitortext in interface TagVisitorpublic void cdata(java.lang.CharSequence cdata)
TagVisitorcdata in interface TagVisitorpublic void xml(Tag tag)
TagVisitorxml in interface TagVisitorpublic void doctype(java.lang.String name,
java.lang.String publicId,
java.lang.String baseUri)
TagVisitorpublicId is null, it is a SYSTEM
directive, otherwise it is PUBLIC.doctype in interface TagVisitorpublic void condComment(java.lang.CharSequence expression,
boolean isStartingTag,
boolean isHidden,
java.lang.CharSequence comment)
TagVisitorexpression if unmodified expression.
comment is optional additional comment and may be null.condComment in interface TagVisitorpublic void error(java.lang.String message)
TagVisitorerror in interface TagVisitormessage - parsing error messageprotected Comment createComment(java.lang.String comment)
Comment.Comment.Comment(Document, String)protected Comment createConditionalComment(java.lang.String comment, boolean isStartingTag, boolean conditionalDownlevelHidden, java.lang.String additionalComment)
Comment.protected Element createElement(java.lang.String name)
protected Element createElement(java.lang.String tagName, boolean voidElement, boolean selfClosed)
Element node.protected DocumentType createDocumentType(java.lang.String value, java.lang.String publicId, java.lang.String baseUri)
protected XmlDeclaration createXmlDeclaration(Tag tag)
Copyright © 2003-2013 Jodd Team