1 57 package com.sun.org.apache.xerces.internal.jaxp.validation; 58 59 import javax.xml.transform.stream.StreamSource ; 60 61 import com.sun.org.apache.xerces.internal.xni.XNIException; 62 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; 63 import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException; 64 import org.xml.sax.SAXException ; 65 import org.xml.sax.SAXParseException ; 66 67 73 public class Util { 74 75 81 public static final XMLInputSource toXMLInputSource( StreamSource in ) { 82 if( in.getReader()!=null ) 83 return new XMLInputSource( 84 in.getPublicId(), in.getSystemId(), in.getSystemId(), 85 in.getReader(), null ); 86 if( in.getInputStream()!=null ) 87 return new XMLInputSource( 88 in.getPublicId(), in.getSystemId(), in.getSystemId(), 89 in.getInputStream(), null ); 90 91 return new XMLInputSource( 92 in.getPublicId(), in.getSystemId(), in.getSystemId() ); 93 } 94 95 98 public static SAXException toSAXException(XNIException e) { 99 if(e instanceof XMLParseException) 100 return toSAXParseException((XMLParseException)e); 101 if( e.getException() instanceof SAXException ) 102 return (SAXException )e.getException(); 103 return new SAXException (e.getMessage(),e.getException()); 104 } 105 106 public static SAXParseException toSAXParseException( XMLParseException e ) { 107 if( e.getException() instanceof SAXParseException ) 108 return (SAXParseException )e.getException(); 109 return new SAXParseException ( e.getMessage(), 110 e.getPublicId(), e.getExpandedSystemId(), 111 e.getLineNumber(), e.getColumnNumber(), 112 e.getException() ); 113 } 114 115 116 } 117 | Popular Tags |