Hello,
I've pulled the latest (as of about 1500GMT) CVS and I'm trying to use it
with Xerces 2.2. I've got input of two XercesDOMParser DOMs for a target
document and a stylesheet, but I'm segfaulting when compiling the
stylesheet. A gdb stack dump shows it dying on some include statements in
the templates.
Basically, I take both of the DOMDocuments and wrap them in
XercesDOMWrapperParsedSource, and then put the wrapped stylesheet in an
XSLTInputSource object.
Any idea what's going wrong?
If I comment out the <xsl:inlude> statements it proceeds and then aborts
in the transformation, too. Who knows WHAT is going on there.
Any hints?
Thanks,
Galen Swint
Here's the function doing the work:
const DOMDocument *doXSLTstep( DOMDocument *nsDataSource, DOMDocument
*tStylesheet )
{
int errval;
char *thisFunc = "doXSLTstep(): ";
const DOMDocument *result;
// create our transformer object
XalanTransformer transformEngine;
// this is to hold output
const XalanAutoPtr<DOMDocument>
theReturnDocument(DOMImplementation::getImplementation()->createDocument());
// This is a class derived from FormatterListener, which
// we'll hook up to Xalan's output stage...
FormatterToXercesDOM theFormatter(theReturnDocument.get(), 0);
cout << thisFunc << "Normalizing." << endl;
nsDataSource->normalize();
tStylesheet->normalize();
XercesDOMSupport theDOMSupport;
XercesParserLiaison theParserLiaison;
// now we have to import a Xalan doc.
cout << thisFunc << "Import NS." << endl;
XercesDOMWrapperParsedSource theParsedSource(nsDataSource,
theParserLiaison, theDOMSupport);
// our stylesheet to apply
cout << thisFunc << "Import SS." << endl;
XercesDOMWrapperParsedSource theSSParsedSource(tStylesheet,
theParserLiaison, theDOMSupport);
assert(theSSParsedSource.getDocument());
cout << thisFunc << theSSParsedSource.getDocument() << endl;
XSLTInputSource *ssInputSource = new
XSLTInputSource(theSSParsedSource.getDocument());
// compile the style sheet
cout << thisFunc << "Compile SS." << endl;
XalanCompiledStylesheet const* theCompiledTemplate = 0;
errval = transformEngine.compileStylesheet( *ssInputSource,
theCompiledTemplate );
cout << thisFunc << "Stylesheet compiled." << endl;
if( errval )
{
cerr << thisFunc << "******Error compiling stylesheet.******" << endl;
cerr << transformEngine.getLastError() << endl;
return NULL;
}
else if( theCompiledTemplate == 0)
{
cerr << thisFunc << "******* compiled is 0 *********" << endl;
}
// transformation
cout << thisFunc << "Begin transform." << endl;
errval = transformEngine.transform( theParsedSource,
theCompiledTemplate, theFormatter);
cout << thisFunc << "End transform." << endl;
if(errval)
{
cout << thisFunc << "XalanError during transform():" <<
transformEngine.getLastError() << endl;
cout << endl;
}
// build something that can go back to the Xerces
result = theReturnDocument.get();
if(result->getDocumentElement() == NULL )
{
cout << thisFunc << "'result' is null" << endl;
return NULL;
}
else
{
// cout << result << endl << "+++++++++++";
}
return result;
}
-------------------------------------
Galen S. Swint
[EMAIL PROTECTED]
http://www.prism.gatech.edu/~gte213x