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 Galen S Swint <zo...@cc.gatech.edu> on 2003/03/27 18:17:05 UTC

Xal 1.5/Xerces 2.2 Segfault

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
swintgs@acm.org
http://www.prism.gatech.edu/~gte213x

Re: Xal 1.5/Xerces 2.2 Segfault

Posted by Galen S Swint <zo...@cc.gatech.edu>.
Hey Dave,
I've opened the following bug:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18464

These are answered in the bug report, but to answer your questions, I'm
using g++ 3.2 on RedHat 8.0, and no, I can't create the bug with the cmd
line utilities.

Yes, I know doing anything with Xerces-parsed XML is not optimal for
Xalan, but we do plan to muck around extensively with both the XSLT and
XML. My feeling is that since XSLT is defined to be valid XML, and since
Xalan is a sister project of Xerces, this sort of may should be considered
for inclusion on the test suite.

Feel free to e-mail me if you need more input (especially if you need more
source code).
Thanks,
Galen Swint

-------------------------------------
Galen S. Swint
swintgs@acm.org
http://www.prism.gatech.edu/~gte213x

On Thu, 27 Mar 2003, David N Bertoni/Cambridge/IBM wrote:

>
>
>
>
> 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
>                       <zorn@cc.gatech.         To:      xalan-c-users@xml.apache.org
>                       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
> swintgs@acm.org
> http://www.prism.gatech.edu/~gte213x
>
>
>

Re: Xal 1.5/Xerces 2.2 Segfault

Posted by David N Bertoni/Cambridge/IBM <da...@us.ibm.com>.



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                                                                                      
                      <zorn@cc.gatech.         To:      xalan-c-users@xml.apache.org                                     
                      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
swintgs@acm.org
http://www.prism.gatech.edu/~gte213x