Index: src/nu/validator/htmlparser/impl/Tokenizer.java =================================================================== --- src/nu/validator/htmlparser/impl/Tokenizer.java (revision 576) +++ src/nu/validator/htmlparser/impl/Tokenizer.java (working copy) @@ -1101,6 +1101,18 @@ } /** + * Reports a warning/error based on the profile + * + * @param profile + * the profile this message belongs to + * @param message + * the message itself + * @throws SAXException + */ + public void note(String profile, String message) throws SAXException { + } + + /** * Reports a warning * * @param message @@ -1193,6 +1205,8 @@ } private void addAttributeWithoutValue() throws SAXException { + note("xhtml2", "Attribute without value"); + // [NOCPP[ if (metaBoundaryPassed && AttributeName.CHARSET == attributeName && ElementName.META == tagName) { @@ -1878,6 +1892,7 @@ */ clearLongStrBuf(); state = Tokenizer.ATTRIBUTE_VALUE_UNQUOTED; + note("xhtml1", "Unquoted attribute value."); reconsume = true; continue stateloop; case '\'': @@ -1933,6 +1948,7 @@ */ state = Tokenizer.ATTRIBUTE_VALUE_UNQUOTED; + note("xhtml1", "Unquoted attribute value."); continue stateloop; } } Index: src/nu/validator/htmlparser/impl/ErrorReportingTokenizer.java =================================================================== --- src/nu/validator/htmlparser/impl/ErrorReportingTokenizer.java (revision 576) +++ src/nu/validator/htmlparser/impl/ErrorReportingTokenizer.java (working copy) @@ -27,6 +27,8 @@ import nu.validator.htmlparser.common.TokenHandler; import nu.validator.htmlparser.common.XmlViolationPolicy; +import java.util.HashMap; + import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; @@ -72,6 +74,8 @@ private char prev; + private HashMap errorProfileMap = null; + /** * @param tokenHandler * @param newAttributesEachTime @@ -121,6 +125,37 @@ this.contentNonXmlCharPolicy = contentNonXmlCharPolicy; } + /** + * Sets the errorProfile. + * + * @param errorProfile + */ + public void setErrorProfile(HashMap errorProfileMap) { + this.errorProfileMap = errorProfileMap; + } + + + /** + * Reports on an event based on profile selected. + * + * @param profile + * the profile this message belongs to + * @param message + * the message itself + * @throws SAXException + */ + public void note(String profile, String message) throws SAXException { + if (errorProfileMap == null) return; + String level = errorProfileMap.get(profile); + if ("warn".equals(level)) { + warn(message); + } else if ("err".equals(level)) { + err(message); + // } else if ("info".equals(level)) { + // info(message); + } + } + protected void startErrorReporting() throws SAXException { alreadyComplainedAboutNonAscii = false; line = linePrev = 0; Index: src/nu/validator/htmlparser/sax/HtmlParser.java =================================================================== --- src/nu/validator/htmlparser/sax/HtmlParser.java (revision 576) +++ src/nu/validator/htmlparser/sax/HtmlParser.java (working copy) @@ -28,6 +28,7 @@ import java.net.URL; import java.util.LinkedList; import java.util.List; +import java.util.HashMap; import nu.validator.htmlparser.common.CharacterHandler; import nu.validator.htmlparser.common.DoctypeExpectation; @@ -136,6 +137,8 @@ private Heuristics heuristics = Heuristics.NONE; + private HashMap errorProfileMap = null; + /** * Instantiates the parser with a fatal XML violation policy. * @@ -153,15 +156,14 @@ } private Tokenizer newTokenizer(TokenHandler handler, boolean newAttributesEachTime) { - if (errorHandler != null) { - return new ErrorReportingTokenizer(handler, newAttributesEachTime); - } else { - if (contentNonXmlCharPolicy == XmlViolationPolicy.ALLOW) { - return new Tokenizer(handler, newAttributesEachTime); - } else { - return new ErrorReportingTokenizer(handler, newAttributesEachTime); - } + if (errorHandler == null && + contentNonXmlCharPolicy == XmlViolationPolicy.ALLOW) { + return new Tokenizer(handler, newAttributesEachTime); } + ErrorReportingTokenizer tokenizer = + new ErrorReportingTokenizer(handler, newAttributesEachTime); + tokenizer.setErrorProfile(errorProfileMap); + return tokenizer; } /** @@ -948,6 +950,14 @@ } /** + * @param errorProfile + * @see nu.validator.htmlparser.impl.errorReportingTokenizer#setErrorProfile(set) + */ + public void setErrorProfile(HashMap errorProfileMap) { + this.errorProfileMap = errorProfileMap; + } + + /** * The policy for non-NCName element and attribute names. * @param namePolicy * @see nu.validator.htmlparser.impl.Tokenizer#setNamePolicy(nu.validator.htmlparser.common.XmlViolationPolicy)