1 16 17 package org.apache.xerces.jaxp.validation; 18 19 import javax.xml.transform.stream.StreamSource ; 20 21 import org.apache.xerces.xni.XNIException; 22 import org.apache.xerces.xni.parser.XMLInputSource; 23 import org.apache.xerces.xni.parser.XMLParseException; 24 import org.xml.sax.SAXException ; 25 import org.xml.sax.SAXParseException ; 26 27 33 final class Util { 34 35 40 public static final XMLInputSource toXMLInputSource( StreamSource in ) { 41 if( in.getReader()!=null ) 42 return new XMLInputSource( 43 in.getPublicId(), in.getSystemId(), in.getSystemId(), 44 in.getReader(), null ); 45 if( in.getInputStream()!=null ) 46 return new XMLInputSource( 47 in.getPublicId(), in.getSystemId(), in.getSystemId(), 48 in.getInputStream(), null ); 49 50 return new XMLInputSource( 51 in.getPublicId(), in.getSystemId(), in.getSystemId() ); 52 } 53 54 57 public static SAXException toSAXException(XNIException e) { 58 if(e instanceof XMLParseException) 59 return toSAXParseException((XMLParseException)e); 60 if( e.getException() instanceof SAXException ) 61 return (SAXException )e.getException(); 62 return new SAXException (e.getMessage(),e.getException()); 63 } 64 65 public static SAXParseException toSAXParseException( XMLParseException e ) { 66 if( e.getException() instanceof SAXParseException ) 67 return (SAXParseException )e.getException(); 68 return new SAXParseException ( e.getMessage(), 69 e.getPublicId(), e.getExpandedSystemId(), 70 e.getLineNumber(), e.getColumnNumber(), 71 e.getException() ); 72 } 73 74 } | Popular Tags |