Package org.opencms.util
Class CmsHtmlValidator
java.lang.Object
org.htmlparser.visitors.NodeVisitor
org.opencms.util.CmsHtmlValidator
Validates HTML.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected org.htmlparser.PrototypicalNodeFactory
Internally degrades Composite tags that do have children in the DOM tree to simple single tags.Returns the validation error messages.int
Returns the number of root elements.boolean
Returns whether the validated HTML is balanced.void
Validates the given HTML string.void
visitEndTag
(org.htmlparser.Tag tag) void
visitTag
(org.htmlparser.Tag tag) Methods inherited from class org.htmlparser.visitors.NodeVisitor
beginParsing, finishedParsing, shouldRecurseChildren, shouldRecurseSelf, visitRemarkNode, visitStringNode
-
Constructor Details
-
CmsHtmlValidator
public CmsHtmlValidator()
-
-
Method Details
-
getMessages
Returns the validation error messages.- Returns:
- the error messages
-
getRootElementCount
Returns the number of root elements.- Returns:
- the number of root elements
-
isBalanced
Returns whether the validated HTML is balanced.- Returns:
true
in case the validated HTML is balanced
-
validate
Validates the given HTML string.- Parameters:
html
- the HTML to validate- Throws:
org.htmlparser.util.ParserException
- in case parsing fails
-
visitEndTag
- Overrides:
visitEndTag
in classorg.htmlparser.visitors.NodeVisitor
- See Also:
-
NodeVisitor.visitEndTag(org.htmlparser.Tag)
-
visitTag
- Overrides:
visitTag
in classorg.htmlparser.visitors.NodeVisitor
- See Also:
-
NodeVisitor.visitTag(org.htmlparser.Tag)
-
configureNoAutoCorrectionTags
Internally degrades Composite tags that do have children in the DOM tree to simple single tags. This allows to avoid auto correction of unclosed HTML tags.- Returns:
- A node factory that will not auto correct open tags
-