473,796 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xerces/xalan exception

Jo
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/LocalFileInputS ource.hpp>
#include <xercesc/parsers/XercesDOMParser .hpp>
#include <xercesc/util/PlatformUtils.h pp>
#include <xercesc/util/XMLString.hpp>

#include <xalanc/XercesParserLia ison/XercesParserLia ison.hpp>
#include <xalanc/XercesParserLia ison/XercesDOMSuppor t.hpp>
#include <xalanc/XalanTransforme r/XalanTransforme r.hpp>
#include <xalanc/XalanTransforme r/XercesDOMWrappe rParsedSource.h pp>

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

using XERCES_CPP_NAME SPACE::XMLPlatf ormUtils;
using XERCES_CPP_NAME SPACE::LocalFil eInputSource;
using XERCES_CPP_NAME SPACE::XMLStrin g;
using XERCES_CPP_NAME SPACE::XMLExcep tion;
using XERCES_CPP_NAME SPACE::DOMExcep tion;

using XALAN_CPP_NAMES PACE::XalanComp iledStylesheet;
using XALAN_CPP_NAMES PACE::XalanDOMS tring;
using XALAN_CPP_NAMES PACE::XalanTran sformer;
using XALAN_CPP_NAMES PACE::XSLTInput Source;
using XALAN_CPP_NAMES PACE::XSLTResul tTarget;
using XALAN_CPP_NAMES PACE::XercesPar serLiaison;
using XALAN_CPP_NAMES PACE::XercesDOM Support;
using XALAN_CPP_NAMES PACE::XercesDOM WrapperParsedSo urce;

int main(void){
try{
// Call the static initializer for Xerces.
XMLPlatformUtil s::Initialize() ;
// Initialize Xalan.
XalanTransforme r::initialize() ;

try{
// Create a XalanTransforme r.
XalanTransforme r theTransformer;

const XSLTInputSource theStylesheetIn putSource("foo. xsl");

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

if (theTransformer .compileStylesh eet(theStyleshe etInputSource,
theStylesheet) != 0)
cerr<<"An error occurred compiling the stylesheet:
"<<theTransform er.getLastError ()<<endl;
else{
XalanDOMString theURI("foo.xml ");

XSLTResultTarge t theResultTarget (cout);

LocalFileInputS ource theXMLInputSour ce(theURI.c_str ());

XercesParserLia ison::DOMParser Type theParser;

theParser.parse (theXMLInputSou rce);

XercesParserLia ison theParserLiaiso n;
XercesDOMSuppor t theDOMSupport;

const XercesDOMWrappe rParsedSource theWrapper(theP arser.getDocume nt(),
theParserLiaiso n, theDOMSupport, theURI);

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

// Terminate Xalan...
XalanTransforme r::terminate();
// Terminate Xerces...
XMLPlatformUtil s::Terminate();
// Clean up the ICU, if it's integrated...
XalanTransforme r::ICUCleanUp() ;
}
catch(...){
cerr << "Initializa tion failed!" << endl;
}

return 0;
}

Jul 20 '05 #1
1 2467
Jo
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/LocalFileInputS ource.hpp>
#include <xercesc/parsers/XercesDOMParser .hpp>
#include <xercesc/util/PlatformUtils.h pp>
#include <xercesc/util/XMLString.hpp>

#include <xalanc/XercesParserLia ison/XercesParserLia ison.hpp>
#include <xalanc/XercesParserLia ison/XercesDOMSuppor t.hpp>
#include <xalanc/XalanTransforme r/XalanTransforme r.hpp>
#include <xalanc/XalanTransforme r/XercesDOMWrappe rParsedSource.h pp>

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

using XERCES_CPP_NAME SPACE::XMLPlatf ormUtils;
using XERCES_CPP_NAME SPACE::LocalFil eInputSource;
using XERCES_CPP_NAME SPACE::XMLStrin g;
using XERCES_CPP_NAME SPACE::XMLExcep tion;
using XERCES_CPP_NAME SPACE::DOMExcep tion;

using XALAN_CPP_NAMES PACE::XalanComp iledStylesheet;
using XALAN_CPP_NAMES PACE::XalanDOMS tring;
using XALAN_CPP_NAMES PACE::XalanTran sformer;
using XALAN_CPP_NAMES PACE::XSLTInput Source;
using XALAN_CPP_NAMES PACE::XSLTResul tTarget;
using XALAN_CPP_NAMES PACE::XercesPar serLiaison;
using XALAN_CPP_NAMES PACE::XercesDOM Support;
using XALAN_CPP_NAMES PACE::XercesDOM WrapperParsedSo urce;

int main(void){
try{
// Call the static initializer for Xerces.
XMLPlatformUtil s::Initialize() ;
// Initialize Xalan.
XalanTransforme r::initialize() ;

try{
// Create a XalanTransforme r.
XalanTransforme r theTransformer;

const XSLTInputSource theStylesheetIn putSource("foo. xsl");

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

if (theTransformer .compileStylesh eet(theStyleshe etInputSource,
theStylesheet) != 0)
cerr<<"An error occurred compiling the stylesheet:
"<<theTransform er.getLastError ()<<endl;
else{
XalanDOMString theURI("foo.xml ");

XSLTResultTarge t theResultTarget (cout);

LocalFileInputS ource theXMLInputSour ce(theURI.c_str ());

XercesParserLia ison::DOMParser Type theParser;

theParser.parse (theXMLInputSou rce);

XercesParserLia ison theParserLiaiso n;
XercesDOMSuppor t theDOMSupport;

const XercesDOMWrappe rParsedSource theWrapper(theP arser.getDocume nt(),
theParserLiaiso n, theDOMSupport, theURI);

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

// Terminate Xalan...
XalanTransforme r::terminate();
// Terminate Xerces...
XMLPlatformUtil s::Terminate();
// Clean up the ICU, if it's integrated...
XalanTransforme r::ICUCleanUp() ;
}
catch(...){
cerr << "Initializa tion failed!" << endl;
}

return 0;
}

If the XercesParserLia ison is allocated dynamically everything runs fine...
Does anybody know what's the catch ?
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1467
by: Volker Jordan | last post by:
Hi, has anyone a conclusion why the xalan xpath expressions dont work with the dom3 implementation from xerces ? I never get a result when the DOM is build via the lsparser. Has someone the xerces lsparser and xalan xapth in a running application ?
0
1155
by: Janice | last post by:
I am new to Xerces, Xalan and C++ but not to XML and XSL. I have been looking at the example but they are over my head. <doc> <item type="x"></item> <item type="y"></item> <item type="z"></item> .... <!-- I need to add/remove <item/> here --> </doc>
7
2147
by: Ganesh Gella | last post by:
Hi All, I am planning to use Xalan to transform XML data by applying xls stylesheets. Here tricky part is, Xalan provides several C++ APIs, which are very much useful if our requirement is just inputting a file and getting a file. Or giving a xerces dom and get a new xerces dom. I would like to know whether any of you tried with their own custom
0
1284
by: cvissy | last post by:
I've been tasked with upgrading the JVM from 1.3 to 1.4, and the third party libraries used by my company on our existing Java framework. I'm most worried about any problems that may occur due to upgrading Xalan and Xerces as our framework performs much XML transformation and processing. Does anyone have a link to known issues with such an upgrade (besides the Xalan / Xerces sites) ?
2
2111
by: Dr. Roger Wießner | last post by:
Hello! I am a newbie to XSLT and need a freeware/GNU Tool to get experience with this new topic. Which one is a good XSLT? Xalan or Saxon, or which one else? Thank you a lot!
0
1201
by: terry.jeske | last post by:
Hello, I am trying to upgrade an application that was previously running on Xalan 1.4.2, to 2.7.0. I have worked out the build issues and now the application compiles with the new xalan and xerces. However, at runtime I get the following error when I try to do a transform: (Location of error unknown)org.xml.sax.SAXException: Can not resolve
3
1844
by: Avalon1178 | last post by:
Hi, I recently downloaded the xalan-c source code in http://mirrors.ccs.neu.edu/Apache/dist/xml/xalan-c I followed the instructions from the apache site on how to build it (I already have xerces downloaded and compiled), however, I'm getting quite a few compile errors. I downloaded and compiled xerces 2.6.0 and I downloaded xalan 1.9.0.
0
1334
by: annelaurence.putz | last post by:
Hello, I have a C++ application which must use Xerces 2.7 and Xalan 1.10 In this Xerces version, there is a MemoryManager Class, and from the web site : ''With the introduction of the configurable memory manager, we didn't want to break users by changing the signature of the existing methods (for example, transcode and replicate). Also, we did not want to provide a default memory manager as it would introduce a side effect with users...
2
2482
by: Gnus | last post by:
Hi all! I have a little(?) problem with external schema location... I'm using xerces/xalan (C++) for doing some actions with some set of xml-files. Some of these files must validating against schema, which location specify in config file ("external" schema). Other files must be validating against schema, which location specify in parsed xml file (via xsi:shemaLocation attribute, "internal" schema) How can I switch between these ...
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10230
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10012
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5442
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.