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); }