mErrorString.Append(NS_LITERAL_STRING("unable to parse xml: invalid or unopen stream encountered."));
mErrorString.AppendLiteral("unable to parse xml: invalid or unopen stream encountered.");
txDriver::parse(istream& aInputStream, const nsAString& aUri){    mErrorString.Truncate();    if (!aInputStream) {        mErrorString.Append(NS_LITERAL_STRING("unable to parse xml: invalid or unopen stream encountered."));        return NS_ERROR_FAILURE;    }    mExpatParser = XML_ParserCreate(nsnull);    if (!mExpatParser) {        return NS_ERROR_OUT_OF_MEMORY;    }    XML_SetUserData(mExpatParser, this);    XML_SetElementHandler(mExpatParser, startElement, endElement);    XML_SetCharacterDataHandler(mExpatParser, charData);#ifdef XML_DTD    XML_SetParamEntityParsing(mExpatParser, XML_PARAM_ENTITY_PARSING_ALWAYS);#endif    XML_SetExternalEntityRefHandler(mExpatParser, externalEntityRefHandler);    XML_SetExternalEntityRefHandlerArg(mExpatParser, this);    XML_SetBase(mExpatParser,                (const XML_Char*)(PromiseFlatString(aUri).get()));    const int bufferSize = 1024;    char buf[bufferSize];    PRBool done;    int success;    mRV = NS_OK;    do {        aInputStream.read(buf, bufferSize);        done = aInputStream.eof();        success = XML_Parse(mExpatParser, buf, aInputStream.gcount(), done);        // mRV is set in onDoneCompiling in case of an error        if (!success || NS_FAILED(mRV)) {            createErrorString();            done = MB_TRUE;        }    } while (!done);    aInputStream.clear();    // clean up    XML_ParserFree(mExpatParser);    mCompiler->doneLoading();    if (!success) {        return NS_ERROR_FAILURE;    }    return mRV;}