javax.xml.stream.XMLReporter Java Examples

The following examples show how to use javax.xml.stream.XMLReporter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StreamScanner.java    From woodstox with Apache License 2.0 6 votes vote down vote up
protected void _reportProblem(XMLReporter rep, XMLValidationProblem prob)
    throws XMLStreamException
{
    if (rep != null) {
        Location loc = prob.getLocation();
        if (loc == null) {
            loc = getLastCharLocation();
            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.
        // [WTSX-157]: need to support XMLReporter2
        if (rep instanceof XMLReporter2) {
            ((XMLReporter2) rep).report(prob);
        } else {
            rep.report(prob.getMessage(), prob.getType(), prob, loc);
        }
    }
}
 
Example #2
Source File: BaseStreamWriter.java    From woodstox with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example #3
Source File: StreamScanner.java    From woodstox with Apache License 2.0 5 votes vote down vote up
public void reportProblem(String probType, String format, Object arg, Object arg2)
    throws XMLStreamException
{
    XMLReporter rep = mConfig.getXMLReporter();
    if (rep != null) {
        _reportProblem(rep, probType,
                        MessageFormat.format(format, new Object[] { arg, arg2 }), null);
    }
}
 
Example #4
Source File: StreamScanner.java    From woodstox with Apache License 2.0 5 votes vote down vote up
@Override
public void reportProblem(Location loc, String probType,
                          String format, Object arg, Object arg2)
    throws XMLStreamException
{
    XMLReporter rep = mConfig.getXMLReporter();
    if (rep != null) {
        String msg = (arg != null || arg2 != null) ?
            MessageFormat.format(format, new Object[] { arg, arg2 }) : format;
        _reportProblem(rep, probType, msg, loc);
    }
}
 
Example #5
Source File: StreamScanner.java    From woodstox with Apache License 2.0 5 votes vote down vote up
protected void _reportProblem(XMLReporter rep, String probType, String msg, Location loc)
    throws XMLStreamException
{
    if (loc == null) {
        loc = getLastCharLocation();
    }
    _reportProblem(rep, new XMLValidationProblem(loc, msg, XMLValidationProblem.SEVERITY_ERROR, probType));
}
 
Example #6
Source File: StreamScanner.java    From woodstox with Apache License 2.0 5 votes vote down vote up
/**
 *<p>
 * Note: this is the base implementation used for implementing
 * <code>ValidationContext</code>
 */
@Override
public void reportValidationProblem(XMLValidationProblem prob)
    throws XMLStreamException
{
    // !!! TBI: Fail-fast vs. deferred modes?
    /* For now let's implement basic functionality: warnings get
     * reported via XMLReporter, errors and fatal errors result in
     * immediate exceptions.
     */
    /* 27-May-2008, TSa: [WSTX-153] Above is incorrect: as per Stax
     *   javadocs for XMLReporter, both warnings and non-fatal errors
     *   (which includes all validation errors) should be reported via
     *   XMLReporter interface, and only fatals should cause an
     *   immediate stream exception (by-passing reporter)
     */
    if (prob.getSeverity() > XMLValidationProblem.SEVERITY_ERROR) {
        throw WstxValidationException.create(prob);
    }
    XMLReporter rep = mConfig.getXMLReporter();
    if (rep != null) {
        _reportProblem(rep, prob);
    } else {
        /* If no reporter, regular non-fatal errors are to be reported
         * as exceptions as well, for backwards compatibility
         */
        if (prob.getSeverity() >= XMLValidationProblem.SEVERITY_ERROR) {
            throw WstxValidationException.create(prob);
        }
    }
}
 
Example #7
Source File: FullDTDReader.java    From woodstox with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #8
Source File: BaseStreamWriter.java    From woodstox with Apache License 2.0 5 votes vote down vote up
@Override
public void reportProblem(XMLValidationProblem prob)
    throws XMLStreamException
{
    // 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.
     */
    /* 27-May-2008, TSa: [WSTX-153] Above is incorrect: as per Stax
     *   javadocs for XMLReporter, both warnings and non-fatal errors
     *   (which includes all validation errors) should be reported via
     *   XMLReporter interface, and only fatals should cause an
     *   immediate stream exception (by-passing reporter)
     */
    if (prob.getSeverity() > XMLValidationProblem.SEVERITY_ERROR) {
        throw WstxValidationException.create(prob);
    }
    XMLReporter rep = mConfig.getProblemReporter();
    if (rep != null) {
        doReportProblem(rep, prob);
    } else {
        /* If no reporter, regular non-fatal errors are to be reported
         * as exceptions as well, for backwards compatibility
         */
        if (prob.getSeverity() >= XMLValidationProblem.SEVERITY_ERROR) {
            throw WstxValidationException.create(prob);
        }
    }
}
 
Example #9
Source File: BaseStreamWriter.java    From woodstox with Apache License 2.0 5 votes vote down vote up
protected void doReportProblem(XMLReporter rep, String probType, String msg, Location loc)
    throws XMLStreamException
{
    if (loc == null) {
        loc = getLocation();
    }
    doReportProblem(rep, new XMLValidationProblem(loc, msg, XMLValidationProblem.SEVERITY_ERROR, probType));
}
 
Example #10
Source File: ReaderBootstrapper.java    From woodstox with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #11
Source File: SAX2StAXBaseWriter.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public SAX2StAXBaseWriter(XMLReporter reporter) {
        this.reporter = reporter;
}
 
Example #12
Source File: SAX2StAXBaseWriter.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public void setXMLReporter(XMLReporter reporter) {
        this.reporter = reporter;
}
 
Example #13
Source File: SAX2StAXBaseWriter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public SAX2StAXBaseWriter(XMLReporter reporter) {
        this.reporter = reporter;
}
 
Example #14
Source File: SAX2StAXBaseWriter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void setXMLReporter(XMLReporter reporter) {
        this.reporter = reporter;
}
 
Example #15
Source File: StaxErrorReporter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 *One must call reset before using any of the function.
 */
public void reset(PropertyManager propertyManager){
    fXMLReporter = (XMLReporter)propertyManager.getProperty(XMLInputFactory.REPORTER);
}
 
Example #16
Source File: SAX2StAXBaseWriter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public SAX2StAXBaseWriter(XMLReporter reporter) {
        this.reporter = reporter;
}
 
Example #17
Source File: SAX2StAXBaseWriter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void setXMLReporter(XMLReporter reporter) {
        this.reporter = reporter;
}
 
Example #18
Source File: StaxErrorReporter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 *One must call reset before using any of the function.
 */
public void reset(PropertyManager propertyManager){
    fXMLReporter = (XMLReporter)propertyManager.getProperty(XMLInputFactory.REPORTER);
}
 
Example #19
Source File: SAX2StAXBaseWriter.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public SAX2StAXBaseWriter(XMLReporter reporter) {
        this.reporter = reporter;
}
 
Example #20
Source File: SAX2StAXBaseWriter.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public void setXMLReporter(XMLReporter reporter) {
        this.reporter = reporter;
}
 
Example #21
Source File: SAX2StAXBaseWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public SAX2StAXBaseWriter(XMLReporter reporter) {
        this.reporter = reporter;
}
 
Example #22
Source File: SAX2StAXBaseWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void setXMLReporter(XMLReporter reporter) {
        this.reporter = reporter;
}
 
Example #23
Source File: StaxErrorReporter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 *One must call reset before using any of the function.
 */
public void reset(PropertyManager propertyManager){
    fXMLReporter = (XMLReporter)propertyManager.getProperty(XMLInputFactory.REPORTER);
}
 
Example #24
Source File: SAX2StAXBaseWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public SAX2StAXBaseWriter(XMLReporter reporter) {
        this.reporter = reporter;
}
 
Example #25
Source File: SAX2StAXBaseWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void setXMLReporter(XMLReporter reporter) {
        this.reporter = reporter;
}
 
Example #26
Source File: StaxErrorReporter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 *One must call reset before using any of the function.
 */
public void reset(PropertyManager propertyManager){
    fXMLReporter = (XMLReporter)propertyManager.getProperty(XMLInputFactory.REPORTER);
}
 
Example #27
Source File: SAX2StAXBaseWriter.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public SAX2StAXBaseWriter(XMLReporter reporter) {
        this.reporter = reporter;
}
 
Example #28
Source File: SAX2StAXBaseWriter.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public void setXMLReporter(XMLReporter reporter) {
        this.reporter = reporter;
}
 
Example #29
Source File: StaxErrorReporter.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 *One must call reset before using any of the function.
 */
public void reset(PropertyManager propertyManager){
    fXMLReporter = (XMLReporter)propertyManager.getProperty(XMLInputFactory.REPORTER);
}
 
Example #30
Source File: SAX2StAXBaseWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public SAX2StAXBaseWriter(XMLReporter reporter) {
        this.reporter = reporter;
}