DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18464>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18464

Xal-C 1.5 xsl:include causes SIGSEGV on stylesheet import from Xerces 2.2

           Summary: Xal-C 1.5 xsl:include causes SIGSEGV on stylesheet
                    import from Xerces 2.2
           Product: XalanC
           Version: 1.4.x
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: Major
          Priority: Other
         Component: XalanC
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


When using Xerces to first parse an XML document and a stylesheet, and then
applying the stylesheet to the XML document using Xalan, xsl:include statements.
I wish to load the stylesheet via Xerces because it will be modified before
being used. The problem does not occur when using either testXSLT or Xalan
command-line tools also compiled from the same source files.

Compiler --version: 
g++ (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)

Xerces 2.2 compiled from source, Xalan 1.5-pre from CVS (27-Mar-2003)

The XercesDOMParseer is created and set to validate, and an error handler
installed. Then, I call the XercesDOMParser and parse both an XML document and a
stylesheet. These are sent to the function doXSLTstep() (given below) where the
stylesheet can be applied to the XML document. In doXSLTstep(), the
compileStylesheet() call triggers a SIGSEGV, apparently while resolving the URLs
of include statements. Commenting out the include statements allows the
compilation to (apparently) succeed.

------------------------
doXSLTstep()
------------------------
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;
  }


  // cout << thisFunc << "Mapping back to Xerces." << endl;
  // build something that can go back to the Xerces and the rest of the program
  result = theReturnDocument.get();


  if(result->getDocumentElement() == NULL )
  {
    cout << thisFunc << "'result' is null" << endl;
    return NULL;
  }
  else
  {
//    cout << result << endl << "+++++++++++";
  }

  return result;
}


------------------------
XSLT file #1 (XalanTest.xsl)
------------------------
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">

<xsl:output method="xml"/>

<xsl:include href="XalanTestInclude.xsl"/>


<xsl:template match="/xip">
  <filledTemplate>
      <xsl:call-template name="includedTemplate"/>
    Hello from main stylesheet.
    </filledTemplate>
</xsl:template>

</xsl:stylesheet>

------------------------
XSLT file #2 (XalanTestInclude.xsl)
------------------------
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">

<!-- this is a mapping of the infopipe types -->
<!-- <xsl:variable name="maptables"
select="document('ECho2mapTables.xml')/mapTables"/> -->

<xsl:template name="includedTemplate">
<xsl:for-each select="/xip/composedPipe"><xsl:text>
</xsl:text><xsl:value-of select="@name"/><xsl:text>:Hello from inside the included.
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


------------------------
XML file for test:
------------------------
<?xml version="1.0"?>
<xip name="AvsStart" version="0.1" >

<datatypes>
  <datatype name="Raw_data" >
    <arg type="integer" name="tag"/>
    <arg type="char" name="ppm1"/>
    <arg type="char" name="ppm2"/>
    <arg type="integer" name="size"/>
    <arg type="integer" name="width"/>
    <arg type="integer" name="height"/>
    <arg type="integer" name="maxval"/>
    <arrayArg type="byte" name="buff" size="size"/>
  </datatype>
</datatypes>

<composedPipe name="test1">
</composedPipe>
<composedPipe name="test2">
</composedPipe>

</xip>

Reply via email to