is.reset ();
}  is.reset();
    private void pushURL (        boolean		isPE,	String		ename,	String		ids [],		// public, system, baseURI	Reader		reader,	InputStream	stream,	String		encoding,	boolean		doResolve    ) throws SAXException, IOException    {	boolean		ignoreEncoding;	String		systemId;	InputSource	source;	if (!isPE)	    dataBufferFlush ();	scratch.setPublicId (ids [0]);	scratch.setSystemId (ids [1]);	// See if we should skip or substitute the entity.	// If we're not skipping, resolving reports startEntity()	// and updates the (handler's) stack of URIs.	if (doResolve) {	    // assert (stream == null && reader == null && encoding == null)	    source = handler.resolveEntity (isPE, ename, scratch, ids [2]);	    if (source == null) {		handler.warn ("skipping entity: " + ename);		handler.skippedEntity (ename);		if (isPE)		    skippedPE = true;		return;	    }	    // we might be using alternate IDs/encoding	    systemId = source.getSystemId ();	    // The following warning and setting systemId was deleted bcause	    // the application has the option of not setting systemId	    // provided that it has set the characte/byte stream.	    /*	    if (systemId == null) {		handler.warn ("missing system ID, using " + ids [1]);		systemId = ids [1];	    }	    */	} else {	    // "[document]", or "[dtd]" via getExternalSubset()	    scratch.setCharacterStream (reader);	    scratch.setByteStream (stream);	    scratch.setEncoding (encoding);	    source = scratch;	    systemId = ids [1];      if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) {        handler.startExternalEntity (ename, systemId,                                     "[document]" == ename);      } else {        handler.startExternalEntity (ename, systemId,                                     "[document]".equals(ename));      }	}	// we may have been given I/O streams directly	if (source.getCharacterStream () != null) {	    if (source.getByteStream () != null)		error ("InputSource has two streams!");	    reader = source.getCharacterStream ();	} else if (source.getByteStream () != null) {	    encoding = source.getEncoding ();	    if (encoding == null)		stream = source.getByteStream ();	    else try {		reader = new InputStreamReader (		    source.getByteStream (),		    encoding);	    } catch (IOException e) {		stream = source.getByteStream ();	    }	} else if (systemId == null)	    error ("InputSource has no URI!");	scratch.setCharacterStream (null);	scratch.setByteStream (null);	scratch.setEncoding (null);	// Push the existing status.	pushInput (ename);	// Create a new read buffer.	// (Note the four-character margin)	readBuffer = new char [READ_BUFFER_MAX + 4];	readBufferPos = 0;	readBufferLength = 0;	readBufferOverflow = -1;	is = null;	line = 1;	column = 0;	currentByteCount = 0;	// If there's an explicit character stream, just	// ignore encoding declarations.	if (reader != null) {	    sourceType = INPUT_READER;	    this.reader = reader;	    tryEncodingDecl (true);	    return;	}		// Else we handle the conversion, and need to ensure	// it's done right.	sourceType = INPUT_STREAM;	if (stream != null) {	    is = stream;	} else {	    // We have to open our own stream to the URL.	    URL url = new URL (systemId);	    externalEntity = url.openConnection ();	    externalEntity.connect ();	    is = externalEntity.getInputStream ();	}	// If we get to here, there must be	// an InputStream available.	if (!is.markSupported ()) {	    is = new BufferedInputStream (is);	}	// Get any external encoding label.	if (encoding == null && externalEntity != null) {	    // External labels can be untrustworthy; filesystems in	    // particular often have the wrong default for content	    // that wasn't locally originated.  Those we autodetect.	    if (!"file".equals (externalEntity.getURL ().getProtocol ())) {		int temp;		// application/xml;charset=something;otherAttr=...		// ... with many variants on 'something'		encoding = externalEntity.getContentType ();		// MHK code (fix for Saxon 5.5.1/007):		// protect against encoding==null		if (encoding==null) {		    temp = -1;		} else {		    temp = encoding.indexOf ("charset");		}		// RFC 2376 sez MIME text defaults to ASCII, but since the		// JDK will create a MIME type out of thin air, we always		// autodetect when there's no explicit charset attribute.		if (temp < 0)		    encoding = null;	// autodetect		else {		    // only this one attribute		    if ((temp = encoding.indexOf (';')) > 0)			encoding = encoding.substring (0, temp);		    if ((temp = encoding.indexOf ('=', temp + 7)) > 0) {			encoding = encoding.substring (temp + 1);			// attributes can have comment fields (RFC 822)			if ((temp = encoding.indexOf ('(')) > 0)			    encoding = encoding.substring (0, temp);			// ... and values may be quoted			if ((temp = encoding.indexOf ('"')) > 0)			    encoding = encoding.substring (temp + 1,				    encoding.indexOf ('"', temp + 2));			encoding.trim ();		    } else {			handler.warn ("ignoring illegal MIME attribute: "				+ encoding);			encoding = null;		    }		}	    }	}	// if we got an external encoding label, use it ...	if (encoding != null) {	    this.encoding = ENCODING_EXTERNAL;	    setupDecoding (encoding);	    ignoreEncoding = true;		// ... else autodetect from first bytes.	} else {	    detectEncoding ();	    ignoreEncoding = false;	}	// Read any XML or text declaration.	// If we autodetected, it may tell us the "real" encoding.	try {	    tryEncodingDecl (ignoreEncoding);	} catch (UnsupportedEncodingException x) {	    encoding = x.getMessage ();	    // if we don't handle the declared encoding,	    // try letting a JVM InputStreamReader do it	    try {		if (sourceType != INPUT_STREAM)		    throw x;		is.reset ();		readBufferPos = 0;		readBufferLength = 0;		readBufferOverflow = -1;		line = 1;		currentByteCount = column = 0;		sourceType = INPUT_READER;		this.reader = new InputStreamReader (is, encoding);		is = null;		tryEncodingDecl (true);	    } catch (IOException e) {		error ("unsupported text encoding",		       encoding,		       null);	    }	}    }