Refine search
protected void doReportProblem(XMLReporter rep, XMLValidationProblem prob) throws XMLStreamException { if (rep != null) { Location loc = prob.getLocation(); if (loc == null) { loc = getLocation(); prob.setLocation(loc); } // Backwards-compatibility fix: add non-null type, if missing: if (prob.getType() == null) { prob.setType(ErrorConsts.WT_VALIDATION); } // [WSTX-154]: was catching and dropping thrown exception: shouldn't. rep.report(prob.getMessage(), prob.getType(), prob, loc); } }
public void reportValidationProblem(String format, Object arg) throws XMLStreamException { String msg = MessageFormat.format(format, new Object[] { arg }); reportProblem(new XMLValidationProblem(getValidationLocation(), msg)); }
if (prob.getSeverity() > XMLValidationProblem.SEVERITY_ERROR) { throw WstxValidationException.create(prob); if (prob.getSeverity() >= XMLValidationProblem.SEVERITY_ERROR) { throw WstxValidationException.create(prob);
private void reportError(String msg, Location loc) throws XMLStreamException { XMLValidationProblem prob = new XMLValidationProblem(loc, msg, XMLValidationProblem.SEVERITY_ERROR); prob.setReporter(this); mContext.reportProblem(prob); } }
public void reportUndeclared(ValidationContext ctxt, XMLValidator dtd) throws XMLStreamException { String msg = MessageFormat.format(ErrorConsts.ERR_DTD_UNDECLARED_ENTITY, new Object[] { (mIsPe ? "parsed" : "general"), mName }); XMLValidationProblem prob = new XMLValidationProblem (mLocation, msg, XMLValidationProblem.SEVERITY_FATAL); prob.setReporter(dtd); ctxt.reportProblem(prob); } }
protected void verifyXmlEncoding(ReaderConfig cfg) throws XMLStreamException { String inputEnc = mInputEncoding; // Close enough? if (StringUtil.equalEncodings(inputEnc, mFoundEncoding)) { return; } /* Ok, maybe the difference is just with endianness indicator? * (UTF-16BE vs. UTF-16)? */ // !!! TBI XMLReporter rep = cfg.getXMLReporter(); if (rep != null) { Location loc = getLocation(); String msg = MessageFormat.format(ErrorConsts.W_MIXED_ENCODINGS, new Object[] { mFoundEncoding, inputEnc }); String type = ErrorConsts.WT_XML_DECL; /* 30-May-2008, tatus: Should wrap all the info as XMValidationProblem * since that's Woodstox' contract wrt. relatedInformation field. */ XMLValidationProblem prob = new XMLValidationProblem(loc, msg, XMLValidationProblem.SEVERITY_WARNING, type); rep.report(msg, type, prob, loc); } }
public static WstxValidationException create(XMLValidationProblem cause) { // Should always get a message Location loc = cause.getLocation(); if (loc == null) { return new WstxValidationException(cause, cause.getMessage()); } return new WstxValidationException(cause, cause.getMessage(), loc); }
public void reportProblem(XMLValidationProblem prob) throws XMLValidationException { // Custom handler set? If so, it'll take care of it: if (mVldProbHandler != null) { mVldProbHandler.reportProblem(prob); return; } /* For now let's implement basic functionality: warnings get * reported via XMLReporter, errors and fatal errors result in * immediate exceptions. */ if (prob.getSeverity() >= XMLValidationProblem.SEVERITY_ERROR) { if (isValidating()) { throw WstxValidationException.create(prob); } } XMLReporter rep = mConfig.getProblemReporter(); if (rep != null) { doReportProblem(rep, ErrorConsts.WT_VALIDATION, prob.getMessage(), prob.getLocation()); } }
protected void doReportProblem(XMLReporter rep, XMLValidationProblem prob, String probType) { if (rep != null) { Location loc = prob.getLocation(); if (loc == null) { loc = getLastCharLocation(); } try { rep.report(prob.getMessage(), probType, prob, loc); } catch (XMLStreamException e) { /* !!! 27-May-2008, TSa: This WRONG: XMLReporter can and * even should throw exceptions in some cases (to signal * it considers some problems as actual fatals) */ System.err.println("Internal error - problem reporting a problem: "+e); } } }
private void _reportWarning(XMLReporter rep, String probType, String msg, Location loc) throws XMLStreamException { if (rep != null) { /* Note: since the problem occurs at DTD (schema) parsing, * not during validation, can not set reporter. */ XMLValidationProblem prob = new XMLValidationProblem (loc, msg, XMLValidationProblem.SEVERITY_WARNING, probType); rep.report(msg, probType, prob, loc); } } }
public void reportValidationProblem(String msg, Location loc, int severity) throws XMLStreamException { reportProblem(new XMLValidationProblem(loc, msg, severity)); }
/** * Method is overridden for two main reasons: first, default method * does not display public/system id information, even if it exists, and * second, default implementation can not handle nested Location * information. */ public String getMessage() { String locMsg = getLocationDesc(); /* Better not use super's message if we do have location information, * since parent's message contains (part of) Location * info; something we can regenerate better... */ if (locMsg == null) { return super.getMessage(); } String msg = getValidationProblem().getMessage(); StringBuffer sb = new StringBuffer(msg.length() + locMsg.length() + 20); sb.append(msg); StringUtil.appendLF(sb); sb.append(" at "); sb.append(locMsg); return sb.toString(); }
public void reportUndeclared(ValidationContext ctxt, XMLValidator dtd) throws XMLStreamException { String msg = MessageFormat.format(ErrorConsts.ERR_DTD_UNDECLARED_ENTITY, new Object[] { (mIsPe ? "parsed" : "general"), mName }); XMLValidationProblem prob = new XMLValidationProblem (mLocation, msg, XMLValidationProblem.SEVERITY_FATAL); prob.setReporter(dtd); ctxt.reportProblem(prob); } }
public static ValidationException create(XMLValidationProblem cause) { // Should always get a message Location loc = cause.getLocation(); if (loc == null) { return new ValidationException(cause, cause.getMessage()); } return new ValidationException(cause, cause.getMessage(), loc); }
public void reportProblem(XMLValidationProblem prob) throws XMLValidationException { // Custom handler set? If so, it'll take care of it: if (mVldProbHandler != null) { mVldProbHandler.reportProblem(prob); return; } /* For now let's implement basic functionality: warnings get * reported via XMLReporter, errors and fatal errors result in * immediate exceptions. */ if (prob.getSeverity() >= XMLValidationProblem.SEVERITY_ERROR) { if (isValidating()) { throw WstxValidationException.create(prob); } } XMLReporter rep = mConfig.getProblemReporter(); if (rep != null) { doReportProblem(rep, ErrorConsts.WT_VALIDATION, prob.getMessage(), prob.getLocation()); } }
protected void doReportProblem(XMLReporter rep, XMLValidationProblem prob, String probType) { if (rep != null) { Location loc = prob.getLocation(); if (loc == null) { loc = getLastCharLocation(); } try { rep.report(prob.getMessage(), probType, prob, loc); } catch (XMLStreamException e) { /* !!! 27-May-2008, TSa: This WRONG: XMLReporter can and * even should throw exceptions in some cases (to signal * it considers some problems as actual fatals) */ System.err.println("Internal error - problem reporting a problem: "+e); } } }
private void _reportWarning(XMLReporter rep, String probType, String msg, Location loc) throws XMLStreamException { if (rep != null) { /* Note: since the problem occurs at DTD (schema) parsing, * not during validation, can not set reporter. */ XMLValidationProblem prob = new XMLValidationProblem (loc, msg, XMLValidationProblem.SEVERITY_WARNING, probType); rep.report(msg, probType, prob, loc); } } }
protected void doReportValidationProblem(String msg, Location loc) throws XMLStreamException { if (loc == null) { loc = getLocation(); } XMLValidationProblem prob = new XMLValidationProblem(loc, msg, XMLValidationProblem.SEVERITY_ERROR); prob.setReporter(this); mContext.reportProblem(prob); }
public void reportValidationProblem(Location loc, String msg) throws XMLStreamException { reportValidationProblem(new XMLValidationProblem(loc, msg)); }
public void reportProblem(XMLValidationProblem problem) throws XMLValidationException { throw new Fault(problem.getMessage(), LOG); } });