本文整理汇总了Java中org.apache.xerces.xni.parser.XMLParseException类的典型用法代码示例。如果您正苦于以下问题:Java XMLParseException类的具体用法?Java XMLParseException怎么用?Java XMLParseException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XMLParseException类属于org.apache.xerces.xni.parser包,在下文中一共展示了XMLParseException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toSAXException
import org.apache.xerces.xni.parser.XMLParseException; //导入依赖的package包/类
static SAXException toSAXException(XNIException e) {
if (e instanceof XMLParseException) {
XMLParseException pe = (XMLParseException)e;
return new SAXParseException(pe.getMessage(),
pe.getPublicId(),
pe.getExpandedSystemId(),
pe.getLineNumber(),
pe.getColumnNumber(),
pe.getException());
}
Exception nested = e.getException();
if (nested == null)
return new SAXException(e.getMessage());
if (nested instanceof SAXException)
return (SAXException)nested;
if (nested instanceof RuntimeException)
throw (RuntimeException)nested;
return new SAXException(nested);
}
示例2: warning
import org.apache.xerces.xni.parser.XMLParseException; //导入依赖的package包/类
/**
* 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);
}
}
示例3: error
import org.apache.xerces.xni.parser.XMLParseException; //导入依赖的package包/类
/**
* 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);
}
}
示例4: printError
import org.apache.xerces.xni.parser.XMLParseException; //导入依赖的package包/类
/** 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();
}
示例5: createXMLParseException
import org.apache.xerces.xni.parser.XMLParseException; //导入依赖的package包/类
/** 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);
}
示例6: convertToSAXParseException
import org.apache.xerces.xni.parser.XMLParseException; //导入依赖的package包/类
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);
}
示例7: printError
import org.apache.xerces.xni.parser.XMLParseException; //导入依赖的package包/类
/** Prints the error message. */
protected void printError(String type, XMLParseException ex) {
System.err.print("[");
System.err.print(type);
System.err.print("] ");
String systemId = ex.getExpandedSystemId();
if (systemId != null) {
int index = systemId.lastIndexOf('/');
if (index != -1)
systemId = systemId.substring(index + 1);
System.err.print(systemId);
}
System.err.print(':');
System.err.print(ex.getLineNumber());
System.err.print(':');
System.err.print(ex.getColumnNumber());
System.err.print(": ");
System.err.print(ex.getMessage());
System.err.println();
System.err.flush();
}
示例8: warning
import org.apache.xerces.xni.parser.XMLParseException; //导入依赖的package包/类
@Override
public void warning(String arg0, String arg1, XMLParseException arg2)
throws XNIException {
if(DEBUG_GENERAL) {
Out.println("warning:");
arg2.printStackTrace(Err.getPrintWriter());
}
}
示例9: warning
import org.apache.xerces.xni.parser.XMLParseException; //导入依赖的package包/类
public void warning( String domain, String key, XMLParseException warningException ) throws XNIException {
if (HTMLParserFactory.isParserWarningsEnabled()) {
System.out.println( "At line " + warningException.getLineNumber() + ", column " + warningException.getColumnNumber() + ": " + warningException.getMessage() );
}
Enumeration listeners = HTMLParserFactory.getHTMLParserListeners().elements();
while (listeners.hasMoreElements()) {
((HTMLParserListener) listeners.nextElement()).warning( _url, warningException.getMessage(), warningException.getLineNumber(), warningException.getColumnNumber() );
}
}
示例10: warning
import org.apache.xerces.xni.parser.XMLParseException; //导入依赖的package包/类
public void warning( String domain, String key, XMLParseException warningException ) throws XNIException {
if (HTMLParserFactory.isParserWarningsEnabled()) {
System.out.println( "At line " + warningException.getLineNumber() + ", column " + warningException.getColumnNumber() + ": " + warningException.getMessage() );
}
Enumeration enum = HTMLParserFactory.getHTMLParserListeners().elements();
while (enum.hasMoreElements()) {
((HTMLParserListener) enum.nextElement()).warning( _url, warningException.getMessage(), warningException.getLineNumber(), warningException.getColumnNumber() );
}
}
示例11: error
import org.apache.xerces.xni.parser.XMLParseException; //导入依赖的package包/类
public void error(String domain, String key,
XMLParseException exception) throws XNIException {
hadError = true;
if (fErrorHandler == null)
return;
super.error(domain, key, exception);
}
示例12: fatalError
import org.apache.xerces.xni.parser.XMLParseException; //导入依赖的package包/类
public void fatalError(String domain, String key,
XMLParseException exception) throws XNIException {
hadError = true;
if (fErrorHandler == null)
return;
super.fatalError(domain, key, exception);
}
示例13: createDOMLocator
import org.apache.xerces.xni.parser.XMLParseException; //导入依赖的package包/类
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());
}
示例14: toSAXException
import org.apache.xerces.xni.parser.XMLParseException; //导入依赖的package包/类
/**
* Reconstructs {@link SAXException} from XNIException.
*/
public static SAXException toSAXException(XNIException e) {
if(e instanceof XMLParseException)
return toSAXParseException((XMLParseException)e);
if( e.getException() instanceof SAXException )
return (SAXException)e.getException();
return new SAXException(e.getMessage(),e.getException());
}
示例15: toSAXParseException
import org.apache.xerces.xni.parser.XMLParseException; //导入依赖的package包/类
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() );
}