Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > xerces/xalan exception

Reply
Thread Tools

xerces/xalan exception

 
 
Jo
Guest
Posts: n/a
 
      06-13-2004
Hello,

What am I doing wrong ? I always end up with an exception regardless
of the provided XML/XSLT (although to ensure the correctness of
the provide input files I've used the ones which comes with the
xalan samples). Is it a memory mishandling error ?
I'm using Xerces 2.4 C++ / Xalan 1.7 C++ and VC6 to compile
the code :

#include <iostream>

#include <xercesc/framework/LocalFileInputSource.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLString.hpp>

#include <xalanc/XercesParserLiaison/XercesParserLiaison.hpp>
#include <xalanc/XercesParserLiaison/XercesDOMSupport.hpp>
#include <xalanc/XalanTransformer/XalanTransformer.hpp>
#include <xalanc/XalanTransformer/XercesDOMWrapperParsedSource.hpp>

using std::cout;
using std::cerr;
using std::endl;
using std::ifstream;
using std:fstream;

using XERCES_CPP_NAMESPACE::XMLPlatformUtils;
using XERCES_CPP_NAMESPACE::LocalFileInputSource;
using XERCES_CPP_NAMESPACE::XMLString;
using XERCES_CPP_NAMESPACE::XMLException;
using XERCES_CPP_NAMESPACE:OMException;

using XALAN_CPP_NAMESPACE::XalanCompiledStylesheet;
using XALAN_CPP_NAMESPACE::XalanDOMString;
using XALAN_CPP_NAMESPACE::XalanTransformer;
using XALAN_CPP_NAMESPACE::XSLTInputSource;
using XALAN_CPP_NAMESPACE::XSLTResultTarget;
using XALAN_CPP_NAMESPACE::XercesParserLiaison;
using XALAN_CPP_NAMESPACE::XercesDOMSupport;
using XALAN_CPP_NAMESPACE::XercesDOMWrapperParsedSource;

int main(void){
try{
// Call the static initializer for Xerces.
XMLPlatformUtils::Initialize();
// Initialize Xalan.
XalanTransformer::initialize();

try{
// Create a XalanTransformer.
XalanTransformer theTransformer;

const XSLTInputSource theStylesheetInputSource("foo.xsl");

// Compile the stylesheet and re-use it...
const XalanCompiledStylesheet* theStylesheet = 0;

if (theTransformer.compileStylesheet(theStylesheetInp utSource,
theStylesheet) != 0)
cerr<<"An error occurred compiling the stylesheet:
"<<theTransformer.getLastError()<<endl;
else{
XalanDOMString theURI("foo.xml");

XSLTResultTarget theResultTarget(cout);

LocalFileInputSource theXMLInputSource(theURI.c_str());

XercesParserLiaison:OMParserType theParser;

theParser.parse(theXMLInputSource);

XercesParserLiaison theParserLiaison;
XercesDOMSupport theDOMSupport;

const XercesDOMWrapperParsedSource theWrapper(theParser.getDocument(),
theParserLiaison, theDOMSupport, theURI);

theTransformer.transform(theWrapper, theStylesheet, theResultTarget);
}
}
catch(...){
cerr << "Exception" << endl;
}

// Terminate Xalan...
XalanTransformer::terminate();
// Terminate Xerces...
XMLPlatformUtils::Terminate();
// Clean up the ICU, if it's integrated...
XalanTransformer::ICUCleanUp();
}
catch(...){
cerr << "Initialization failed!" << endl;
}

return 0;
}



 
Reply With Quote
 
 
 
 
Jo
Guest
Posts: n/a
 
      06-15-2004
Jo wrote:
> Hello,
>
> What am I doing wrong ? I always end up with an exception regardless
> of the provided XML/XSLT (although to ensure the correctness of
> the provide input files I've used the ones which comes with the
> xalan samples). Is it a memory mishandling error ?
> I'm using Xerces 2.4 C++ / Xalan 1.7 C++ and VC6 to compile
> the code :
>
> #include <iostream>
>
> #include <xercesc/framework/LocalFileInputSource.hpp>
> #include <xercesc/parsers/XercesDOMParser.hpp>
> #include <xercesc/util/PlatformUtils.hpp>
> #include <xercesc/util/XMLString.hpp>
>
> #include <xalanc/XercesParserLiaison/XercesParserLiaison.hpp>
> #include <xalanc/XercesParserLiaison/XercesDOMSupport.hpp>
> #include <xalanc/XalanTransformer/XalanTransformer.hpp>
> #include <xalanc/XalanTransformer/XercesDOMWrapperParsedSource.hpp>
>
> using std::cout;
> using std::cerr;
> using std::endl;
> using std::ifstream;
> using std:fstream;
>
> using XERCES_CPP_NAMESPACE::XMLPlatformUtils;
> using XERCES_CPP_NAMESPACE::LocalFileInputSource;
> using XERCES_CPP_NAMESPACE::XMLString;
> using XERCES_CPP_NAMESPACE::XMLException;
> using XERCES_CPP_NAMESPACE:OMException;
>
> using XALAN_CPP_NAMESPACE::XalanCompiledStylesheet;
> using XALAN_CPP_NAMESPACE::XalanDOMString;
> using XALAN_CPP_NAMESPACE::XalanTransformer;
> using XALAN_CPP_NAMESPACE::XSLTInputSource;
> using XALAN_CPP_NAMESPACE::XSLTResultTarget;
> using XALAN_CPP_NAMESPACE::XercesParserLiaison;
> using XALAN_CPP_NAMESPACE::XercesDOMSupport;
> using XALAN_CPP_NAMESPACE::XercesDOMWrapperParsedSource;
>
> int main(void){
> try{
> // Call the static initializer for Xerces.
> XMLPlatformUtils::Initialize();
> // Initialize Xalan.
> XalanTransformer::initialize();
>
> try{
> // Create a XalanTransformer.
> XalanTransformer theTransformer;
>
> const XSLTInputSource theStylesheetInputSource("foo.xsl");
>
> // Compile the stylesheet and re-use it...
> const XalanCompiledStylesheet* theStylesheet = 0;
>
> if (theTransformer.compileStylesheet(theStylesheetInp utSource,
> theStylesheet) != 0)
> cerr<<"An error occurred compiling the stylesheet:
> "<<theTransformer.getLastError()<<endl;
> else{
> XalanDOMString theURI("foo.xml");
>
> XSLTResultTarget theResultTarget(cout);
>
> LocalFileInputSource theXMLInputSource(theURI.c_str());
>
> XercesParserLiaison:OMParserType theParser;
>
> theParser.parse(theXMLInputSource);
>
> XercesParserLiaison theParserLiaison;
> XercesDOMSupport theDOMSupport;
>
> const XercesDOMWrapperParsedSource theWrapper(theParser.getDocument(),
> theParserLiaison, theDOMSupport, theURI);
>
> theTransformer.transform(theWrapper, theStylesheet, theResultTarget);
> }
> }
> catch(...){
> cerr << "Exception" << endl;
> }
>
> // Terminate Xalan...
> XalanTransformer::terminate();
> // Terminate Xerces...
> XMLPlatformUtils::Terminate();
> // Clean up the ICU, if it's integrated...
> XalanTransformer::ICUCleanUp();
> }
> catch(...){
> cerr << "Initialization failed!" << endl;
> }
>
> return 0;
> }
>
>
>

If the XercesParserLiaison is allocated dynamically everything runs fine...
Does anybody know what's the catch ?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception of type 'System.Web.HttpUnhandledException' wasthrown.Exception has been thrown by the target of an invocation.System.WebSystem.Exception jobs ASP .Net 1 11-16-2007 05:57 PM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
Throw Exception Vs Throw New Exception Kerri ASP .Net 2 10-27-2003 02:13 PM
Re: bizaar exception that isn't really an exception jeff ASP .Net 3 06-26-2003 01:02 PM
Re: bizaar exception that isn't really an exception jeff ASP .Net 0 06-24-2003 12:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57