Hi,
I get an unhandelt exception during a prozession with Xalan
stylesheet and xml source. I was running a Sample from xalan where it uses memory buffering and it worked...
than I did only a little change and it throws an exception
and I dont understand why and what am I making wrong.
********************
try
  {
   // Call the static initializer for Xerces...
   XMLPlatformUtils::Initialize();
 
   {
    // Initialize the Xalan XSLT subsystem...
    XSLTInit      theInit;
 
    // Create some support objects that are necessary for running the processor...
    XalanSourceTreeDOMSupport  theDOMSupport;
    XalanSourceTreeParserLiaison theParserLiaison(theDOMSupport);
 
    // Hook the two together...
    theDOMSupport.setParserLiaison(&theParserLiaison);
 
    // Create some more support objects...
    XSLTProcessorEnvSupportDefault theXSLTProcessorEnvSupport;
    XObjectFactoryDefault   theXObjectFactory;
    XPathFactoryDefault    theXPathFactory;
 
    // Create a processor...
    XSLTEngineImpl theProcessor(
      theParserLiaison,
      theXSLTProcessorEnvSupport,
      theDOMSupport,
      theXObjectFactory,
      theXPathFactory);
 
    // Connect the processor to the support object...
    theXSLTProcessorEnvSupport.setProcessor(&theProcessor);
 
    // Create a stylesheet construction context, and a stylesheet
    // execution context...
    StylesheetConstructionContextDefault theConstructionContext(
       theProcessor,
       theXSLTProcessorEnvSupport,
       theXPathFactory);
 
    StylesheetExecutionContextDefault  theExecutionContext(
       theProcessor,
       theXSLTProcessorEnvSupport,
       theDOMSupport,
       theXObjectFactory);
 
    // A simple input document...
    const char* const  theInputDocument = document;
 
    // A "hello world" stylesheet.  Note that the encoding for the output is US-ASCII,
    // since we're writing to a string.  It could be any encoding, but "binary" encodings,
    // or encodings that could produce multi-byte characters would require transcoding on
    // some platforms.
    const char* const  theStylesheet =
"<?xml version='1.0'?>\
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>\
<xsl:output encoding='US-ASCII'/>\
<xsl:template match='doc'>\
<out><xsl:value-of select='1234'/></out>\
</xsl:template>\
</xsl:stylesheet>";
 
    // Our input streams...
    istrstream theInputDocumentStream(theInputDocument, strlen(theInputDocument));
    istrstream theStylesheetStream(theStylesheet, strlen(theStylesheet));
 
    // Our input sources...
    XSLTInputSource  theInputSource(&theInputDocumentStream);
    XSLTInputSource  theStylesheetSource(&theStylesheetStream);
 
    // A fake system ID for the input sources...
    const XalanDOMString theSystemID("Memory buffer");
 
    // Set the system IDs...
    theInputSource.setSystemId(c_wstr(theSystemID));
    theStylesheetSource.setSystemId(c_wstr(theSystemID));
 
    
#if defined(SIMPLE_STREAM_USE_STATIC_BUFFER)
    char    theData[100];
 
    ostrstream   theOutputStream(theData, sizeof(theData));
#else
    ostrstream   theOutputStream;
#endif
 
    XSLTResultTarget theResultTarget(&theOutputStream);
 
    theProcessor.process(
       theInputSource,
       theStylesheetSource,
       theResultTarget,
       theConstructionContext,
       theExecutionContext);// ?????????????????????? exception
 
    
    theOutputStream << '\0';
 
#if !defined(SIMPLE_STREAM_USE_STATIC_BUFFER)
    // Get a pointer to the string, and store it in a XalanArrayAutoPtr,
    // since it will need to be deleted.
    const XalanArrayAutoPtr<char> theGuard(theOutputStream.str());
 
    char* const theData = theGuard.get();
    TheData=theData;
#endif
    
   }
 
   // Call the static terminator for Xerces...
   XMLPlatformUtils::Terminate();
  }
 
  catch(...)
  {
   AfxMessageBox("Exception cought!!");//?????????????????????why
  }
*************************
the content of that document is foo.xml from the example
and is correct in memory. Who can tell me what is zhe problem ?

Reply via email to