472,975 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,975 software developers and data experts.

XalanNode getNodeValue always returns NULL

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.
Jul 20 '05 #1
2 7064


Rene van Hoek wrote:

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.


What kind of node is that, an element node? For element nodes the
nodeValue is defined to be null, it is not (as many people expect) the
content of the element.
Here is the W3C DOM definition of Node and nodeValue:
http://www.w3.org/TR/2000/REC-DOM-Le...#ID-1950641247

You might want
./seq/text()
as the XPath expression you evaluate, that returns (with
selectSingleNode) as single text node and for text nodes the nodeValue
is the text content.

This is all based on my experience with other DOM and XPath
implementations I know, I don't use Xalan/Xerces C myself.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
Martin Honnen <ma*******@yahoo.de> wrote in message news:<41**********************@newsread4.arcor-online.net>...
Rene van Hoek wrote:

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.


What kind of node is that, an element node? For element nodes the
nodeValue is defined to be null, it is not (as many people expect) the
content of the element.
Here is the W3C DOM definition of Node and nodeValue:
http://www.w3.org/TR/2000/REC-DOM-Le...#ID-1950641247

You might want
./seq/text()
as the XPath expression you evaluate, that returns (with
selectSingleNode) as single text node and for text nodes the nodeValue
is the text content.

This is all based on my experience with other DOM and XPath
implementations I know, I don't use Xalan/Xerces C myself.


Hi,

Thanks for your reply. The returned node type is an element node.
Indeed according to the specification, the nodevalue is defined to be
NULL. When I do ./seq/text() I get an text node, which has an value.

Thanks.
Jul 20 '05 #3

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

Similar topics

4
by: David | last post by:
Hello , I'm trying to parse an XML document a get spicific tags such as email in the code below. I'm using xerces 2.4. However I don't manage to get the value for the email. Can anybody help. ...
0
by: Waseem | last post by:
Hi I have looked and tried everything and i still cant sort this out i have no idea why this wont work I am using Xerces Perl on Windows and Debian to try this and it wont work on both of...
9
by: fochie | last post by:
Greetings, I'm having a problem when I try to GET a file from my server via xmlhttp when using Mozilla. With IE I can get any type of file fine, get/display headers fine, etc. With Mozilla,...
8
by: Brian | last post by:
This is causing me to not be able to create a relation in my dataset. Here's my code: dc1 = ds.Tables .Columns ; dc2 = ds.Tables .Columns ; dr1 = new System.Data.DataRelation...
10
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a...
3
by: axlq | last post by:
I wrote the function below to get the vertical scroll position of an anchor. That is, a URL of the form http://www.example.com/mypage.html#anchorname should scroll to the point on the page that...
10
by: syntego | last post by:
I think I have discovered a bug in the handling of null values (vs NULL values) passed as parameters to a stored proc. I have always believed that the database handled NULL and null the same. ...
3
by: Jon L | last post by:
Hi, I'm hoping someone can help me with this problem. I'm not sure whether the problem lies with the software or with my understanding of the language. I'm using the Microsoft.XMLDOM object...
3
ADezii
by: ADezii | last post by:
Null as it relates to database development is one of life's little mysteries and a topic of total confusion for novices who venture out into the database world. A Null Value is not zero (0), a zero...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.