R
Rene van Hoek
Hi,
I am using Xalan 1.8.0 and Xerces 2.6.0 in C++.
I have an XML document which I first transform into an other XML
document using an XSL styelsheet. Then I want to parse with
XPathEvaluator the new XML document.
I succeed in transforming, also in parsing with the XPathEvaluator.
But I can not get any nodeValue, getNodeValue() returns NULL.
A snapshot of the code is below:
for (int cnt = 0; cnt < length; cnt++) {
DOMNode* sheet = sheets->item(cnt);
XercesDocumentWrapper theXalanDoc(theDOM, true, true, true);
XercesWrapperNavigator theNavigator(&theXalanDoc);
XalanNode* theSheet = theXalanDoc.mapNode(sheet);
XalanSourceTreeDOMSupport theDOMSupport;
XalanDocumentPrefixResolver thePrefixResolver(&theXalanDoc);
XPathEvaluator theEvaluator;
// OK, let's find the context node...
XalanNode* const theSeqNode
=theEvaluator.selectSingleNode(theDOMSupport, theSheet, L"./seq",
thePrefixResolver);
XalanNode::NodeType type = theSeqNode->getNodeType();
//getNodeValue Always returns NULL ????
XalanDOMString sheet_seq = theSeqNode->getNodeValue();
}
I am new in using Xerces and Xalan, so this code may seem clumsy to
you. The getNodeType returns an value I excpet, also the method
getNodeName(), getNodeValue() always returns NULL. The XML source has
an value.
The complete code is below:
DOMDocument * theDOM =
DOMImplementation::getImplementation()->createDocument();
XMLErrorHandling::XMLError xml_error(_sloc);
FormatterToXercesDOM theFormatter(theDOM, NULL);
try {
XalanTransformer theXalanTransformer;
theXalanTransformer.setErrorHandler(&xml_error);
theXalanTransformer.transform("xml_file.xml",
L"questionaire_retrieve_sheets.xsl", theFormatter);
}
catch (...) {
theDOM->release();
theDOM = NULL;
return 0;
}
int length = 0;
DOMNodeList* sheets = NULL;
sheets = theDOM->getElementsByTagName(std::wstring(L"sheet").c_str());
if (NULL == sheets)
return 0;
length = sheets->getLength();
for (int cnt = 0; cnt < length; cnt++) {
DOMNode* sheet = sheets->item(cnt);
XercesDocumentWrapper theXalanDoc(theDOM, true, true, true);
XercesWrapperNavigator theNavigator(&theXalanDoc);
XalanNode* theSheet = theXalanDoc.mapNode(sheet);
XalanSourceTreeDOMSupport theDOMSupport;
XalanDocumentPrefixResolver thePrefixResolver(&theXalanDoc);
XPathEvaluator theEvaluator;
// OK, let's find the context node...
XalanNode* const theSeqNode =
theEvaluator.selectSingleNode(theDOMSupport, theSheet, L"./seq",
thePrefixResolver);
XalanNode::NodeType type = theSeqNode->getNodeType();
XalanDOMString sheet_seq = theSeqNode->getNodeValue();
}
Thanks you in advance.
I am using Xalan 1.8.0 and Xerces 2.6.0 in C++.
I have an XML document which I first transform into an other XML
document using an XSL styelsheet. Then I want to parse with
XPathEvaluator the new XML document.
I succeed in transforming, also in parsing with the XPathEvaluator.
But I can not get any nodeValue, getNodeValue() returns NULL.
A snapshot of the code is below:
for (int cnt = 0; cnt < length; cnt++) {
DOMNode* sheet = sheets->item(cnt);
XercesDocumentWrapper theXalanDoc(theDOM, true, true, true);
XercesWrapperNavigator theNavigator(&theXalanDoc);
XalanNode* theSheet = theXalanDoc.mapNode(sheet);
XalanSourceTreeDOMSupport theDOMSupport;
XalanDocumentPrefixResolver thePrefixResolver(&theXalanDoc);
XPathEvaluator theEvaluator;
// OK, let's find the context node...
XalanNode* const theSeqNode
=theEvaluator.selectSingleNode(theDOMSupport, theSheet, L"./seq",
thePrefixResolver);
XalanNode::NodeType type = theSeqNode->getNodeType();
//getNodeValue Always returns NULL ????
XalanDOMString sheet_seq = theSeqNode->getNodeValue();
}
I am new in using Xerces and Xalan, so this code may seem clumsy to
you. The getNodeType returns an value I excpet, also the method
getNodeName(), getNodeValue() always returns NULL. The XML source has
an value.
The complete code is below:
DOMDocument * theDOM =
DOMImplementation::getImplementation()->createDocument();
XMLErrorHandling::XMLError xml_error(_sloc);
FormatterToXercesDOM theFormatter(theDOM, NULL);
try {
XalanTransformer theXalanTransformer;
theXalanTransformer.setErrorHandler(&xml_error);
theXalanTransformer.transform("xml_file.xml",
L"questionaire_retrieve_sheets.xsl", theFormatter);
}
catch (...) {
theDOM->release();
theDOM = NULL;
return 0;
}
int length = 0;
DOMNodeList* sheets = NULL;
sheets = theDOM->getElementsByTagName(std::wstring(L"sheet").c_str());
if (NULL == sheets)
return 0;
length = sheets->getLength();
for (int cnt = 0; cnt < length; cnt++) {
DOMNode* sheet = sheets->item(cnt);
XercesDocumentWrapper theXalanDoc(theDOM, true, true, true);
XercesWrapperNavigator theNavigator(&theXalanDoc);
XalanNode* theSheet = theXalanDoc.mapNode(sheet);
XalanSourceTreeDOMSupport theDOMSupport;
XalanDocumentPrefixResolver thePrefixResolver(&theXalanDoc);
XPathEvaluator theEvaluator;
// OK, let's find the context node...
XalanNode* const theSeqNode =
theEvaluator.selectSingleNode(theDOMSupport, theSheet, L"./seq",
thePrefixResolver);
XalanNode::NodeType type = theSeqNode->getNodeType();
XalanDOMString sheet_seq = theSeqNode->getNodeValue();
}
Thanks you in advance.