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 Francesc Guim Bernat <fg...@fib.upc.es> on 2004/05/01 14:36:44 UTC
Getting in troubles problems using Xerces 2.4 and Xalan 1.7.
Dear Colleagues,
I'm trying to use Xalan and Xerces together, nevertheless i'm not
able to run succesfully any of the codes that i've developed. I'm always
getting and exception when the XalanSourceTreeParserLiaison or
XercesParserLiaison are used (the exception is not and
XalanDOMExcpetion, XSLException or DOMExcpetion). Also, when i'm running
one of samples of the Xalanc source code provided by the library, the
sample XPathWrapper, an exception is triggered. I don't how to solve
this problem, i've tried many things but i'm always fail.... actually,
i'm not too sure of what would be the error... I'm using Xerces 2.4 and
Xalan 1.7.
Anyone can orient me ? what i'm doing wrong ? I atach my source code at
the end of this mail.
i will be thankful for any help
cheers,
Francesc
LISTMSG XMLeanDBStatisticMsg::selectMsgs(char* selector)
{
LISTMSG llista;
XPathEvaluator::initialize();
XalanSourceTreeDOMSupport theDOMSupport;
this->document->normalize();
XercesParserLiaison * Liasion = new XercesParserLiaison();
XalanDocument* proxyDocument;
XalanElement* xalContextNode ;
try
{
proxyDocument = Liasion->createDocument(this->document);
xalContextNode = proxyDocument->getDocumentElement();
}
catch(XalanDOMException& error)
{
return llista;
}
XPathEnvSupportDefault theEnvSupport;
XObjectFactoryDefault theXObjectFactory;
XPathExecutionContextDefault theExecutionContext(theEnvSupport,
theDOMSupport, theXObjectFactory);
XPathConstructionContextDefault theXPathConstructionContext;
XPathFactoryDefault theXPathFactory;
XPathProcessorImpl theXPathProcessor;
try
{
XPath* const xpath = theXPathFactory.create();
theXPathProcessor.initXPath(*xpath,
theXPathConstructionContext,
XalanDOMString(selector),
ElementPrefixResolverProxy(xalContextNode,
theEnvSupport, theDOMSupport));
XObjectPtr xObj = xpath->execute(xalContextNode,
ElementPrefixResolverProxy(xalContextNode,
theEnvSupport, theDOMSupport),
theExecutionContext);
XalanNode* primer;
DOMNode * actual;
const NodeRefListBase& resultat = xObj->nodeset();
XercesDocumentWrapper * theWrapper =
Liasion->mapDocumentToWrapper(proxyDocument);
for(unsigned int i=0;i<resultat.getLength();i++)
{
primer = resultat.item(i);
//Un cop es te l'element el modifiquem afegint-hi un atribut.
actual = (DOMElement*)(theWrapper->mapNode(resultat.item(i)));
//Creem un element del tipus XMLeanDBStatisticMsg i l'afegim
a la llista
XMLeanStatisticMsg * nou = new XMLeanStatisticMsg(actual);
llista.push_back(nou);
}
}
catch(XalanDOMException& error)
{
return llista;
}
catch(XSLException& error)
{
XalanDOMString er = error.getMessage();
return llista;
}
catch (...)
{
return llista;
}
return llista;
}
Re: Getting in troubles problems using Xerces 2.4 and Xalan 1.7.
Posted by da...@us.ibm.com.
Hi,
It looks like you're not initializing Xerces-C, which is required. Take a
look at any of the sample programs for more information.
Dave
Francesc Guim
Bernat To: xalan-c-users@xml.apache.org
<fguim@fib.upc.e cc: (bcc: David N Bertoni/Cambridge/IBM)
s> Subject: Getting in troubles problems using Xerces 2.4 and Xalan 1.7.
05/01/2004 05:36
AM
Please respond
to xalan-c-users
Dear Colleagues,
I'm trying to use Xalan and Xerces together, nevertheless i'm not
able to run succesfully any of the codes that i've developed. I'm always
getting and exception when the XalanSourceTreeParserLiaison or
XercesParserLiaison are used (the exception is not and
XalanDOMExcpetion, XSLException or DOMExcpetion). Also, when i'm running
one of samples of the Xalanc source code provided by the library, the
sample XPathWrapper, an exception is triggered. I don't how to solve
this problem, i've tried many things but i'm always fail.... actually,
i'm not too sure of what would be the error... I'm using Xerces 2.4 and
Xalan 1.7.
Anyone can orient me ? what i'm doing wrong ? I atach my source code at
the end of this mail.
i will be thankful for any help
cheers,
Francesc
LISTMSG XMLeanDBStatisticMsg::selectMsgs(char* selector)
{
LISTMSG llista;
XPathEvaluator::initialize();
XalanSourceTreeDOMSupport theDOMSupport;
this->document->normalize();
XercesParserLiaison * Liasion = new XercesParserLiaison();
XalanDocument* proxyDocument;
XalanElement* xalContextNode ;
try
{
proxyDocument = Liasion->createDocument(this->document);
xalContextNode = proxyDocument->getDocumentElement();
}
catch(XalanDOMException& error)
{
return llista;
}
XPathEnvSupportDefault theEnvSupport;
XObjectFactoryDefault theXObjectFactory;
XPathExecutionContextDefault theExecutionContext(theEnvSupport,
theDOMSupport, theXObjectFactory);
XPathConstructionContextDefault theXPathConstructionContext;
XPathFactoryDefault theXPathFactory;
XPathProcessorImpl theXPathProcessor;
try
{
XPath* const xpath = theXPathFactory.create();
theXPathProcessor.initXPath(*xpath,
theXPathConstructionContext,
XalanDOMString(selector),
ElementPrefixResolverProxy(xalContextNode,
theEnvSupport, theDOMSupport));
XObjectPtr xObj = xpath->execute(xalContextNode,
ElementPrefixResolverProxy(xalContextNode,
theEnvSupport, theDOMSupport),
theExecutionContext);
XalanNode* primer;
DOMNode * actual;
const NodeRefListBase& resultat = xObj->nodeset();
XercesDocumentWrapper * theWrapper =
Liasion->mapDocumentToWrapper(proxyDocument);
for(unsigned int i=0;i<resultat.getLength();i++)
{
primer = resultat.item(i);
//Un cop es te l'element el modifiquem afegint-hi un atribut.
actual = (DOMElement*)(theWrapper->mapNode(resultat.item(i)));
//Creem un element del tipus XMLeanDBStatisticMsg i l'afegim
a la llista
XMLeanStatisticMsg * nou = new XMLeanStatisticMsg(actual);
llista.push_back(nou);
}
}
catch(XalanDOMException& error)
{
return llista;
}
catch(XSLException& error)
{
XalanDOMString er = error.getMessage();
return llista;
}
catch (...)
{
return llista;
}
return llista;
}