@Override protected void errQuoteOrLtInAttributeNameOrNull(char c) throws SAXException { if (c == '<') { err("\u201C<\u201D in attribute name. Probable cause: \u201C>\u201D missing immediately before."); } else if (c != '\uFFFD') { err("Quote \u201C" + c + "\u201D in attribute name. Probable cause: Matching quote missing somewhere earlier."); } }
@Override protected void errBadCharBeforeAttributeNameOrNull(char c) throws SAXException { if (c == '<') { err("Saw \u201C<\u201D when expecting an attribute name. Probable cause: Missing \u201C>\u201D immediately before."); } else if (c == '=') { errEqualsSignBeforeAttributeName(); } else if (c != '\uFFFD') { errQuoteBeforeAttributeName(c); } }
@Override protected char errNcrControlChar(char ch) throws SAXException { switch (contentNonXmlCharPolicy) { case FATAL: fatal("Character reference expands to a control character (" + toUPlusString((char) value) + ")."); break; case ALTER_INFOSET: ch = '\uFFFD'; // fall through case ALLOW: err("Character reference expands to a control character (" + toUPlusString((char) value) + ")."); } return ch; }
/** * @see nu.validator.htmlparser.impl.Tokenizer#errAstralNonCharacter(int) */ @Override protected void errAstralNonCharacter(int ch) throws SAXException { err("Character reference expands to an astral non-character (" + toUPlusString(value) + ")."); }
@Override protected void maybeWarnPrivateUse(char ch) throws SAXException { if (errorHandler != null && isPrivateUse(ch)) { warnAboutPrivateUseChar(); } }
switch (c) { case '\u0000': err("Saw U+0000 in stream."); case '\t': case '\r': case '\u000C': if (contentNonXmlCharPolicy == XmlViolationPolicy.FATAL) { fatal("This document is not mappable to XML 1.0 without data loss due to " + toUPlusString(c) + " which is not a legal XML 1.0 character."); } else { warn("This document is not mappable to XML 1.0 without data loss due to " + toUPlusString(c) + " which is not a legal XML 1.0 character."); int intVal = (prev << 10) + c + SURROGATE_OFFSET; if ((intVal & 0xFFFE) == 0xFFFE) { err("Astral non-character."); if (isAstralPrivateUse(intVal)) { warnAboutPrivateUseChar(); switch (contentNonXmlCharPolicy) { case FATAL: fatal("Forbidden code point " + toUPlusString(c) + "."); break;
private Tokenizer newTokenizer(TokenHandler handler, boolean newAttributesEachTime) { if (errorHandler == null && transitionHandler == null && contentNonXmlCharPolicy == XmlViolationPolicy.ALLOW) { return new Tokenizer(handler, newAttributesEachTime); } ErrorReportingTokenizer tokenizer = new ErrorReportingTokenizer(handler, newAttributesEachTime); tokenizer.setErrorProfile(errorProfileMap); return tokenizer; }
@Override protected void maybeWarnPrivateUseAstral() throws SAXException { if (errorHandler != null && isAstralPrivateUse(value)) { warnAboutPrivateUseChar(); } }
@Override protected void errWarnLtSlashInRcdata() throws SAXException { if (html4) { err((stateSave == Tokenizer.DATA ? "CDATA" : "RCDATA") + " element \u201C" + endTagExpectation + "\u201D contained the string \u201C</\u201D, but it was not the start of the end tag. (HTML4-only error)"); } else { warn((stateSave == Tokenizer.DATA ? "CDATA" : "RCDATA") + " element \u201C" + endTagExpectation + "\u201D contained the string \u201C</\u201D, but this did not close the element."); } }
@Override protected void errNoDigitsInNCR() throws SAXException { err("No digits after \u201C" + strBufToString() + "\u201D."); }
private Tokenizer newTokenizer(TokenHandler handler, boolean newAttributesEachTime) { if (errorHandler == null && transitionHandler == null && contentNonXmlCharPolicy == XmlViolationPolicy.ALLOW) { return new Tokenizer(handler, newAttributesEachTime); } else { return new ErrorReportingTokenizer(handler, newAttributesEachTime); } }
@Override protected void noteUnquotedAttributeValue() throws SAXException { note("xhtml1", "Unquoted attribute value."); }
public void setTransitionHandler(TransitionHandler transitionHandler) { if (tokenizer instanceof ErrorReportingTokenizer) { ErrorReportingTokenizer ert = (ErrorReportingTokenizer) tokenizer; ert.setTransitionHandler(transitionHandler); } else if (transitionHandler != null) { throw new IllegalStateException("Attempt to set a transition handler on a plain tokenizer."); } }
switch (c) { case '\u0000': err("Saw U+0000 in stream."); case '\t': case '\r': case '\u000C': if (contentNonXmlCharPolicy == XmlViolationPolicy.FATAL) { fatal("This document is not mappable to XML 1.0 without data loss due to " + toUPlusString(c) + " which is not a legal XML 1.0 character."); } else { warn("This document is not mappable to XML 1.0 without data loss due to " + toUPlusString(c) + " which is not a legal XML 1.0 character."); int intVal = (prev << 10) + c + SURROGATE_OFFSET; if ((intVal & 0xFFFE) == 0xFFFE) { err("Astral non-character."); if (isAstralPrivateUse(intVal)) { warnAboutPrivateUseChar(); switch (contentNonXmlCharPolicy) { case FATAL: fatal("Forbidden code point " + toUPlusString(c) + "."); break;
/** * @see nu.validator.htmlparser.impl.Tokenizer#errAstralNonCharacter(int) */ @Override protected void errAstralNonCharacter(int ch) throws SAXException { err("Character reference expands to an astral non-character (" + toUPlusString(value) + ")."); }
private Tokenizer newTokenizer(TokenHandler handler, boolean newAttributesEachTime) { if (errorHandler == null && transitionHandler == null && contentNonXmlCharPolicy == XmlViolationPolicy.ALLOW) { return new Tokenizer(handler, newAttributesEachTime); } ErrorReportingTokenizer tokenizer = new ErrorReportingTokenizer(handler, newAttributesEachTime); tokenizer.setErrorProfile(errorProfileMap); return tokenizer; }
@Override protected void maybeWarnPrivateUse(char ch) throws SAXException { if (errorHandler != null && isPrivateUse(ch)) { warnAboutPrivateUseChar(); } }
@Override protected void maybeWarnPrivateUseAstral() throws SAXException { if (errorHandler != null && isAstralPrivateUse(value)) { warnAboutPrivateUseChar(); } }
private Tokenizer newTokenizer(TokenHandler handler, boolean newAttributesEachTime) { if (errorHandler == null && transitionHandler == null && contentNonXmlCharPolicy == XmlViolationPolicy.ALLOW) { return new Tokenizer(handler, newAttributesEachTime); } else { return new ErrorReportingTokenizer(handler, newAttributesEachTime); } }
@Override protected void noteAttributeWithoutValue() throws SAXException { note("xhtml2", "Attribute without value"); }