com.sun.org.apache.xerces.internal.xni.parser.XMLParseException Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.xni.parser.XMLParseException. 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: DOMErrorHandlerWrapper.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reports an error. Errors are non-fatal and usually signify that the
 * document is invalid with respect to its grammar(s).
 *
 * @param domain    The domain of the error. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this error.
 * @param key       The error key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */
public void error(String domain, String key,
                  XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_ERROR;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode= fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
 
Example #2
Source File: XPointerErrorHandler.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/** Prints the error message. */
private void printError(String type, XMLParseException ex) {

    fOut.print("[");
    fOut.print(type);
    fOut.print("] ");
    String systemId = ex.getExpandedSystemId();
    if (systemId != null) {
        int index = systemId.lastIndexOf('/');
        if (index != -1)
            systemId = systemId.substring(index + 1);
        fOut.print(systemId);
    }
    fOut.print(':');
    fOut.print(ex.getLineNumber());
    fOut.print(':');
    fOut.print(ex.getColumnNumber());
    fOut.print(": ");
    fOut.print(ex.getMessage());
    fOut.println();
    fOut.flush();

}
 
Example #3
Source File: DefaultErrorHandler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Prints the error message. */
private void printError(String type, XMLParseException ex) {

    fOut.print("[");
    fOut.print(type);
    fOut.print("] ");
    String systemId = ex.getExpandedSystemId();
    if (systemId != null) {
        int index = systemId.lastIndexOf('/');
        if (index != -1)
            systemId = systemId.substring(index + 1);
        fOut.print(systemId);
    }
    fOut.print(':');
    fOut.print(ex.getLineNumber());
    fOut.print(':');
    fOut.print(ex.getColumnNumber());
    fOut.print(": ");
    fOut.print(ex.getMessage());
    fOut.println();
    fOut.flush();

}
 
Example #4
Source File: XPointerErrorHandler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Prints the error message. */
private void printError(String type, XMLParseException ex) {

    fOut.print("[");
    fOut.print(type);
    fOut.print("] ");
    String systemId = ex.getExpandedSystemId();
    if (systemId != null) {
        int index = systemId.lastIndexOf('/');
        if (index != -1)
            systemId = systemId.substring(index + 1);
        fOut.print(systemId);
    }
    fOut.print(':');
    fOut.print(ex.getLineNumber());
    fOut.print(':');
    fOut.print(ex.getColumnNumber());
    fOut.print(": ");
    fOut.print(ex.getMessage());
    fOut.println();
    fOut.flush();

}
 
Example #5
Source File: SchemaContentHandler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
static void convertToSAXParseException(XMLParseException e) throws SAXException {
    Exception ex = e.getException();
    if (ex == null) {
        // must be a parser exception; mine it for locator info and throw
        // a SAXParseException
        LocatorImpl locatorImpl = new LocatorImpl();
        locatorImpl.setPublicId(e.getPublicId());
        locatorImpl.setSystemId(e.getExpandedSystemId());
        locatorImpl.setLineNumber(e.getLineNumber());
        locatorImpl.setColumnNumber(e.getColumnNumber());
        throw new SAXParseException(e.getMessage(), locatorImpl);
    }
    if (ex instanceof SAXException) {
        // why did we create an XMLParseException?
        throw (SAXException) ex;
    }
    throw new SAXException(ex);
}
 
Example #6
Source File: SchemaContentHandler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static void convertToSAXParseException(XMLParseException e) throws SAXException {
    Exception ex = e.getException();
    if (ex == null) {
        // must be a parser exception; mine it for locator info and throw
        // a SAXParseException
        LocatorImpl locatorImpl = new LocatorImpl();
        locatorImpl.setPublicId(e.getPublicId());
        locatorImpl.setSystemId(e.getExpandedSystemId());
        locatorImpl.setLineNumber(e.getLineNumber());
        locatorImpl.setColumnNumber(e.getColumnNumber());
        throw new SAXParseException(e.getMessage(), locatorImpl);
    }
    if (ex instanceof SAXException) {
        // why did we create an XMLParseException?
        throw (SAXException) ex;
    }
    throw new SAXException(ex);
}
 
Example #7
Source File: DOMErrorHandlerWrapper.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reports a warning. Warnings are non-fatal and can be safely ignored
 * by most applications.
 *
 * @param domain    The domain of the warning. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this warning.
 * @param key       The warning key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */

public void warning(String domain, String key,
                    XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_WARNING;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode = fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
 
Example #8
Source File: SchemaContentHandler.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
static void convertToSAXParseException(XMLParseException e) throws SAXException {
    Exception ex = e.getException();
    if (ex == null) {
        // must be a parser exception; mine it for locator info and throw
        // a SAXParseException
        LocatorImpl locatorImpl = new LocatorImpl();
        locatorImpl.setPublicId(e.getPublicId());
        locatorImpl.setSystemId(e.getExpandedSystemId());
        locatorImpl.setLineNumber(e.getLineNumber());
        locatorImpl.setColumnNumber(e.getColumnNumber());
        throw new SAXParseException(e.getMessage(), locatorImpl);
    }
    if (ex instanceof SAXException) {
        // why did we create an XMLParseException?
        throw (SAXException) ex;
    }
    throw new SAXException(ex);
}
 
Example #9
Source File: SchemaContentHandler.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static void convertToSAXParseException(XMLParseException e) throws SAXException {
    Exception ex = e.getException();
    if (ex == null) {
        // must be a parser exception; mine it for locator info and throw
        // a SAXParseException
        LocatorImpl locatorImpl = new LocatorImpl();
        locatorImpl.setPublicId(e.getPublicId());
        locatorImpl.setSystemId(e.getExpandedSystemId());
        locatorImpl.setLineNumber(e.getLineNumber());
        locatorImpl.setColumnNumber(e.getColumnNumber());
        throw new SAXParseException(e.getMessage(), locatorImpl);
    }
    if (ex instanceof SAXException) {
        // why did we create an XMLParseException?
        throw (SAXException) ex;
    }
    throw new SAXException(ex);
}
 
Example #10
Source File: SchemaContentHandler.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
static void convertToSAXParseException(XMLParseException e) throws SAXException {
    Exception ex = e.getException();
    if (ex == null) {
        // must be a parser exception; mine it for locator info and throw
        // a SAXParseException
        LocatorImpl locatorImpl = new LocatorImpl();
        locatorImpl.setPublicId(e.getPublicId());
        locatorImpl.setSystemId(e.getExpandedSystemId());
        locatorImpl.setLineNumber(e.getLineNumber());
        locatorImpl.setColumnNumber(e.getColumnNumber());
        throw new SAXParseException(e.getMessage(), locatorImpl);
    }
    if (ex instanceof SAXException) {
        // why did we create an XMLParseException?
        throw (SAXException) ex;
    }
    throw new SAXException(ex);
}
 
Example #11
Source File: ErrorHandlerWrapper.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Creates an XMLParseException from a SAXParseException. */
protected static XMLParseException createXMLParseException(SAXParseException exception) {
    final String fPublicId = exception.getPublicId();
    final String fExpandedSystemId = exception.getSystemId();
    final int fLineNumber = exception.getLineNumber();
    final int fColumnNumber = exception.getColumnNumber();
    XMLLocator location = new XMLLocator() {
        public String getPublicId() { return fPublicId; }
        public String getExpandedSystemId() { return fExpandedSystemId; }
        public String getBaseSystemId() { return null; }
        public String getLiteralSystemId() { return null; }
        public int getColumnNumber() { return fColumnNumber; }
        public int getLineNumber() { return fLineNumber; }
        public int getCharacterOffset() { return -1; }
        public String getEncoding() { return null; }
        public String getXMLVersion() { return null; }
    };
    return new XMLParseException(location, exception.getMessage(),exception);
}
 
Example #12
Source File: ErrorHandlerWrapper.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/** Creates an XMLParseException from a SAXParseException. */
protected static XMLParseException createXMLParseException(SAXParseException exception) {
    final String fPublicId = exception.getPublicId();
    final String fExpandedSystemId = exception.getSystemId();
    final int fLineNumber = exception.getLineNumber();
    final int fColumnNumber = exception.getColumnNumber();
    XMLLocator location = new XMLLocator() {
        public String getPublicId() { return fPublicId; }
        public String getExpandedSystemId() { return fExpandedSystemId; }
        public String getBaseSystemId() { return null; }
        public String getLiteralSystemId() { return null; }
        public int getColumnNumber() { return fColumnNumber; }
        public int getLineNumber() { return fLineNumber; }
        public int getCharacterOffset() { return -1; }
        public String getEncoding() { return null; }
        public String getXMLVersion() { return null; }
    };
    return new XMLParseException(location, exception.getMessage(),exception);
}
 
Example #13
Source File: DOMErrorHandlerWrapper.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reports an error. Errors are non-fatal and usually signify that the
 * document is invalid with respect to its grammar(s).
 *
 * @param domain    The domain of the error. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this error.
 * @param key       The error key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */
public void error(String domain, String key,
                  XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_ERROR;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode= fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
 
Example #14
Source File: DOMErrorHandlerWrapper.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reports a warning. Warnings are non-fatal and can be safely ignored
 * by most applications.
 *
 * @param domain    The domain of the warning. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this warning.
 * @param key       The warning key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */

public void warning(String domain, String key,
                    XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_WARNING;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode = fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
 
Example #15
Source File: SchemaContentHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static void convertToSAXParseException(XMLParseException e) throws SAXException {
    Exception ex = e.getException();
    if (ex == null) {
        // must be a parser exception; mine it for locator info and throw
        // a SAXParseException
        LocatorImpl locatorImpl = new LocatorImpl();
        locatorImpl.setPublicId(e.getPublicId());
        locatorImpl.setSystemId(e.getExpandedSystemId());
        locatorImpl.setLineNumber(e.getLineNumber());
        locatorImpl.setColumnNumber(e.getColumnNumber());
        throw new SAXParseException(e.getMessage(), locatorImpl);
    }
    if (ex instanceof SAXException) {
        // why did we create an XMLParseException?
        throw (SAXException) ex;
    }
    throw new SAXException(ex);
}
 
Example #16
Source File: DefaultErrorHandler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/** Prints the error message. */
private void printError(String type, XMLParseException ex) {

    fOut.print("[");
    fOut.print(type);
    fOut.print("] ");
    String systemId = ex.getExpandedSystemId();
    if (systemId != null) {
        int index = systemId.lastIndexOf('/');
        if (index != -1)
            systemId = systemId.substring(index + 1);
        fOut.print(systemId);
    }
    fOut.print(':');
    fOut.print(ex.getLineNumber());
    fOut.print(':');
    fOut.print(ex.getColumnNumber());
    fOut.print(": ");
    fOut.print(ex.getMessage());
    fOut.println();
    fOut.flush();

}
 
Example #17
Source File: DOMErrorHandlerWrapper.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reports an error. Errors are non-fatal and usually signify that the
 * document is invalid with respect to its grammar(s).
 *
 * @param domain    The domain of the error. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this error.
 * @param key       The error key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */
public void error(String domain, String key,
                  XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_ERROR;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode= fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
 
Example #18
Source File: DOMErrorHandlerWrapper.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Reports an error. Errors are non-fatal and usually signify that the
 * document is invalid with respect to its grammar(s).
 *
 * @param domain    The domain of the error. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this error.
 * @param key       The error key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */
public void error(String domain, String key,
                  XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_ERROR;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode= fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
 
Example #19
Source File: DOMErrorHandlerWrapper.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Reports a warning. Warnings are non-fatal and can be safely ignored
 * by most applications.
 *
 * @param domain    The domain of the warning. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this warning.
 * @param key       The warning key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */

public void warning(String domain, String key,
                    XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_WARNING;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode = fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
 
Example #20
Source File: ErrorHandlerWrapper.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/** Creates an XMLParseException from a SAXParseException. */
protected static XMLParseException createXMLParseException(SAXParseException exception) {
    final String fPublicId = exception.getPublicId();
    final String fExpandedSystemId = exception.getSystemId();
    final int fLineNumber = exception.getLineNumber();
    final int fColumnNumber = exception.getColumnNumber();
    XMLLocator location = new XMLLocator() {
        public String getPublicId() { return fPublicId; }
        public String getExpandedSystemId() { return fExpandedSystemId; }
        public String getBaseSystemId() { return null; }
        public String getLiteralSystemId() { return null; }
        public int getColumnNumber() { return fColumnNumber; }
        public int getLineNumber() { return fLineNumber; }
        public int getCharacterOffset() { return -1; }
        public String getEncoding() { return null; }
        public String getXMLVersion() { return null; }
    };
    return new XMLParseException(location, exception.getMessage(),exception);
}
 
Example #21
Source File: SchemaContentHandler.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
static void convertToSAXParseException(XMLParseException e) throws SAXException {
    Exception ex = e.getException();
    if (ex == null) {
        // must be a parser exception; mine it for locator info and throw
        // a SAXParseException
        LocatorImpl locatorImpl = new LocatorImpl();
        locatorImpl.setPublicId(e.getPublicId());
        locatorImpl.setSystemId(e.getExpandedSystemId());
        locatorImpl.setLineNumber(e.getLineNumber());
        locatorImpl.setColumnNumber(e.getColumnNumber());
        throw new SAXParseException(e.getMessage(), locatorImpl);
    }
    if (ex instanceof SAXException) {
        // why did we create an XMLParseException?
        throw (SAXException) ex;
    }
    throw new SAXException(ex);
}
 
Example #22
Source File: DOMErrorHandlerWrapper.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reports a warning. Warnings are non-fatal and can be safely ignored
 * by most applications.
 *
 * @param domain    The domain of the warning. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this warning.
 * @param key       The warning key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */

public void warning(String domain, String key,
                    XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_WARNING;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode = fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
 
Example #23
Source File: SchemaContentHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static void convertToSAXParseException(XMLParseException e) throws SAXException {
    Exception ex = e.getException();
    if (ex == null) {
        // must be a parser exception; mine it for locator info and throw
        // a SAXParseException
        LocatorImpl locatorImpl = new LocatorImpl();
        locatorImpl.setPublicId(e.getPublicId());
        locatorImpl.setSystemId(e.getExpandedSystemId());
        locatorImpl.setLineNumber(e.getLineNumber());
        locatorImpl.setColumnNumber(e.getColumnNumber());
        throw new SAXParseException(e.getMessage(), locatorImpl);
    }
    if (ex instanceof SAXException) {
        // why did we create an XMLParseException?
        throw (SAXException) ex;
    }
    throw new SAXException(ex);
}
 
Example #24
Source File: SchemaContentHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static void convertToSAXParseException(XMLParseException e) throws SAXException {
    Exception ex = e.getException();
    if (ex == null) {
        // must be a parser exception; mine it for locator info and throw
        // a SAXParseException
        LocatorImpl locatorImpl = new LocatorImpl();
        locatorImpl.setPublicId(e.getPublicId());
        locatorImpl.setSystemId(e.getExpandedSystemId());
        locatorImpl.setLineNumber(e.getLineNumber());
        locatorImpl.setColumnNumber(e.getColumnNumber());
        throw new SAXParseException(e.getMessage(), locatorImpl);
    }
    if (ex instanceof SAXException) {
        // why did we create an XMLParseException?
        throw (SAXException) ex;
    }
    throw new SAXException(ex);
}
 
Example #25
Source File: SchemaContentHandler.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static void convertToSAXParseException(XMLParseException e) throws SAXException {
    Exception ex = e.getException();
    if (ex == null) {
        // must be a parser exception; mine it for locator info and throw
        // a SAXParseException
        LocatorImpl locatorImpl = new LocatorImpl();
        locatorImpl.setPublicId(e.getPublicId());
        locatorImpl.setSystemId(e.getExpandedSystemId());
        locatorImpl.setLineNumber(e.getLineNumber());
        locatorImpl.setColumnNumber(e.getColumnNumber());
        throw new SAXParseException(e.getMessage(), locatorImpl);
    }
    if (ex instanceof SAXException) {
        // why did we create an XMLParseException?
        throw (SAXException) ex;
    }
    throw new SAXException(ex);
}
 
Example #26
Source File: ErrorHandlerWrapper.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/** Creates an XMLParseException from a SAXParseException. */
protected static XMLParseException createXMLParseException(SAXParseException exception) {
    final String fPublicId = exception.getPublicId();
    final String fExpandedSystemId = exception.getSystemId();
    final int fLineNumber = exception.getLineNumber();
    final int fColumnNumber = exception.getColumnNumber();
    XMLLocator location = new XMLLocator() {
        public String getPublicId() { return fPublicId; }
        public String getExpandedSystemId() { return fExpandedSystemId; }
        public String getBaseSystemId() { return null; }
        public String getLiteralSystemId() { return null; }
        public int getColumnNumber() { return fColumnNumber; }
        public int getLineNumber() { return fLineNumber; }
        public int getCharacterOffset() { return -1; }
        public String getEncoding() { return null; }
        public String getXMLVersion() { return null; }
    };
    return new XMLParseException(location, exception.getMessage(),exception);
}
 
Example #27
Source File: DOMErrorImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private DOMLocatorImpl createDOMLocator(XMLParseException exception) {
    // assuming DOMLocator wants the *expanded*, not the literal, URI of the doc... - neilg
    return new DOMLocatorImpl(exception.getLineNumber(),
                              exception.getColumnNumber(),
                              exception.getCharacterOffset(),
                              exception.getExpandedSystemId());
}
 
Example #28
Source File: ErrorHandlerWrapper.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** Creates a SAXParseException from an XMLParseException. */
protected static SAXParseException createSAXParseException(XMLParseException exception) {
    return new SAXParseException(exception.getMessage(),
                                 exception.getPublicId(),
                                 exception.getExpandedSystemId(),
                                 exception.getLineNumber(),
                                 exception.getColumnNumber(),
                                 exception.getException());
}
 
Example #29
Source File: ErrorHandlerAdaptor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void warning( String domain, String key, XMLParseException e ) {
    try {
        getErrorHandler().warning( Util.toSAXParseException(e) );
    } catch( SAXException se ) {
        throw new WrappedSAXException(se);
    }
}
 
Example #30
Source File: Util.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static SAXParseException toSAXParseException( XMLParseException e ) {
    if( e.getException() instanceof SAXParseException )
        return (SAXParseException)e.getException();
    return new SAXParseException( e.getMessage(),
    e.getPublicId(), e.getExpandedSystemId(),
    e.getLineNumber(), e.getColumnNumber(),
    e.getException() );
}