Package org.opencms.util
Class CmsHtmlValidator
java.lang.Object
org.htmlparser.visitors.NodeVisitor
org.opencms.util.CmsHtmlValidator
Validates HTML.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.htmlparser.PrototypicalNodeFactoryInternally degrades Composite tags that do have children in the DOM tree to simple single tags.Returns the validation error messages.intReturns the number of root elements.booleanReturns whether the validated HTML is balanced.voidValidates the given HTML string.voidvisitEndTag(org.htmlparser.Tag tag) voidvisitTag(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:
truein 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:
visitEndTagin classorg.htmlparser.visitors.NodeVisitor- See Also:
-
visitTag
- Overrides:
visitTagin classorg.htmlparser.visitors.NodeVisitor- See Also:
-
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
-