[xsl] "Primary document entity cound not be opened"

Subject: [xsl] "Primary document entity cound not be opened"
From: "SP/Nowotny Florian" <fn@xxxxxxx>
Date: Fri, 19 Dec 2003 16:14:58 +0100
I'm using Xalan C++ API Version 1.4 together with Xerces C++ 2.1.0 API in a Win32-Application.
I'm talking aubout the problem first and after that I'm describing my code.

The Problem:
At about 1% of our 4650 customers Xalan raises the error: "primary document entity could not be opened". It happens in environments where the XSL-Dokument is at localhost and where the document is on a seperate server. The problem isn't affectet by using UNC-paths or paths containing blanks.
It is independent of the plattform: There is one customer where our application works fine on a Win2k client but does not on a Win98 client. Both are using the same documents from a server. We also have a Problem with a single Win2k Worksation (documents at localhost).
So I did a command line programm only doing this job and using the same internal code. The transformation works fine on all the workstations. How can that be?

The Code:
After initializing the XalanTransformer
XalanTransformer pXalan = new XalanTransformer();

I'm transforming one XML-Document (1) using an XSL-Document (2) fist. I'm transforming the resulting XML-Dokument (3) again using another XSL-Document (4) to get the final XML-Dokument (5).
I'm working with Streams: First I use the Win32-API function ifstream( filename, ios::in ) to konvert the file into a stream (1s) because I'd like to use this stream (1s) with the contructor of an XSLTInputSource( 1s ).

But this didn't always work because of a problem with the STL-Streams. Sometimes the internal get-Pointer does not point to the starting position of the stream but to the end! This is a bug of the STL-API and this is why I sort of shake the Stream before I give it to the Contructor of XSLTInputSource. I'm shaking it the following way:
// putting the get-Pointer to the beginning of the buffer
 	(void) XmlStream.seekg( 0 ); 
// Then copiing the buffer into a temporary stringstream
stringstream temp;
temp << XmlStream.rdbuf() << ends;
// Because even this isn't enough...
temp.str( temp.str() );
This is how it always works in my environment and in our test environments.

Does anybody has the same or similar problem with xalan/xerces? 
Can anybody help me to get along with the bug of STL in a better way?
I'd be glad to discuss some answers and I am running out of ideas.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread