Class CmsHtmlValidator


  • public class CmsHtmlValidator
    extends org.htmlparser.visitors.NodeVisitor
    Validates HTML.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected org.htmlparser.PrototypicalNodeFactory configureNoAutoCorrectionTags()
      Internally degrades Composite tags that do have children in the DOM tree to simple single tags.
      java.util.List<CmsMessageContainer> getMessages()
      Returns the validation error messages.
      int getRootElementCount()
      Returns the number of root elements.
      boolean isBalanced()
      Returns whether the validated HTML is balanced.
      void validate​(java.lang.String html)
      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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getRootElementCount

        public int getRootElementCount()
        Returns the number of root elements.

        Returns:
        the number of root elements
      • isBalanced

        public boolean isBalanced()
        Returns whether the validated HTML is balanced.

        Returns:
        true in case the validated HTML is balanced
      • validate

        public void validate​(java.lang.String html)
                      throws org.htmlparser.util.ParserException
        Validates the given HTML string.

        Parameters:
        html - the HTML to validate
        Throws:
        org.htmlparser.util.ParserException - in case parsing fails
      • visitEndTag

        public void visitEndTag​(org.htmlparser.Tag tag)
        Overrides:
        visitEndTag in class org.htmlparser.visitors.NodeVisitor
        See Also:
        NodeVisitor.visitEndTag(org.htmlparser.Tag)
      • visitTag

        public void visitTag​(org.htmlparser.Tag tag)
        Overrides:
        visitTag in class org.htmlparser.visitors.NodeVisitor
        See Also:
        NodeVisitor.visitTag(org.htmlparser.Tag)
      • configureNoAutoCorrectionTags

        protected org.htmlparser.PrototypicalNodeFactory 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