Hi Galen,
Some more information would be really helpful to figure this out:
1. What's the platform and compiler?
2. Can you reproduce this with the command line utilities? Try using
the Xalan and testXSLT utilities to see what happens.
The path you're using of compiling a stylesheet from a DOM has never been
well tested, so we may have some bugs there. Can you open a bug report and
attach a minimal source file that we can use to reproduce the problem,
along with sample input documents?
By the way, compiling a stylesheet this way is probably not optimal. Are
you doing this because you're building the stylesheet tree
programmatically?
Dave
Galen S Swint
<[EMAIL PROTECTED] To:
[email protected]
edu> cc: (bcc: David N
Bertoni/Cambridge/IBM)
Subject: Xal 1.5/Xerces 2.2
Segfault
03/27/2003 09:17
AM
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