You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by Dave Connet <co...@entelos.com> on 2002/10/03 01:19:36 UTC

Problems using an istream in XSLTInputSource

I'm trying to convert our 1.3 code to using 1.4 and have run into a
problem...

When our app first starts up, it compiles a number of stylesheets using the
following method:
	stringstream inputXSL;
	inputXSL << "a string loaded from a resource" << ends;
	XSLTInputSource theStylesheetSource(&inputXSL);
	theStylesheetSource.setSystemId(kSysIdXSLInput); // just a string
	theXalanTransformer.compileStylesheet(theStylesheetSource,
compiledSheet);
In 1.3, this works fine. In 1.4, I get an exception thrown.

In investigating, I've discovered that I can pass a filename directly to
compileStylesheet and that will work. But passing either a string or an
ifstream, somewhere deep down things go wrong. It looks like it's actually
the xerces parsing that fails, but I haven't looked into it any more than
that (xerces throws a SAXParseException)

To recreate this, I modified the CompileStylesheet program:
			//const char*		theXSLFileName = "foo.xsl";
const char* xsl = "<?xml version=\"1.0\"?>\n\
<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"
version=\"1.0\">\n\
<xsl:template match=\"doc\">\n\
<out><xsl:value-of select=\".\"/></out>\n\
</xsl:template>\n\
</xsl:stylesheet>\n";
			stringstream in;
			in << xsl << ends;
			XSLTInputSource theXSLFileName(&in);
			theXSLFileName.setSystemId(L"foo.xsl");

(Plus I added a <sstream> include and a "using namespace std")

Running this produces:
Fatal Error at (file foo.xsl, line 4, column 17): An exception occurred!
Type:UnexpectedEOFException, Message:The end of input was not expected
CompileStylesheet Error: An exception occurred! Type:UnexpectedEOFException,
Message:The end of input was not expected

It looks like the stream isn't being read correctly. Another thing that I
see with our stylesheets is a failure because it was expecting a closing
<xsl:for-each> tag - but according to the line/col numbers, it's sitting in
it.

Dave Connet