Hi,

I am a new user to Xerces-C++. I want to apply xsl transformation to xml stored in a buffer and get the output into a buffer.

The StreamTransform.cpp example reads from a buffer and writes output to a stream. I tried modifying this to write to a buffer. I followed the same pattern defined in the example for converting the buffer to a stream.

-----------------
//code from StreamTransform example to convert
//input buffer to XSLTInputsource

istrstream theXMLStream(theInputDocument, strlen(theInputDocument)); istrstream theXSLStream(theStyleSheet, strlen(theStyleSheet));
        XALAN_USING_XALAN(XalanDOMString)
          XALAN_USING_XALAN(XSLTInputSource)
        XSLTInputSource  inputSource(&theXSLStream);
        inputSource.setSystemId(XalanDOMString("foo").c_str());

//code I added to convert output buffer to
//XSLTResultTarget

ostrstream theOutputStream(outputBuffer, strlen(outputBuffer));
        XALAN_USING_XALAN(XalanDOMString)
          XALAN_USING_XALAN(XSLTResultTarget)
        XSLTResultTarget outputStream(&theOutputStream);

// Do the transform.
theResult = theXalanTransformer.transform(&theXMLStream, inputSource, outputStream);
----------------------

It compiles fine. But when I run it, I get

StreamTransform Error:
XalanStdOutputStreamWriteException: Error writing to standard stream.The error code is '2'. (, line -1, column -1)

Could someone please tell me what is wrong here? If anyone can provide me with an example of writing the transform output to a buffer, that will be very helpful.

thank you,
Nithya

Reply via email to