473,769 Members | 1,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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);

XercesDocumentW rapper theXalanDoc(the DOM, true, true, true);
XercesWrapperNa vigator theNavigator(&t heXalanDoc);
XalanNode* theSheet = theXalanDoc.map Node(sheet);

XalanSourceTree DOMSupport theDOMSupport;
XalanDocumentPr efixResolver thePrefixResolv er(&theXalanDoc );
XPathEvaluator theEvaluator;

// OK, let's find the context node...
XalanNode* const theSeqNode
=theEvaluator.s electSingleNode (theDOMSupport, theSheet, L"./seq",
thePrefixResolv er);
XalanNode::Node Type 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 =
DOMImplementati on::getImplemen tation()->createDocument ();
XMLErrorHandlin g::XMLError xml_error(_sloc );
FormatterToXerc esDOM theFormatter(th eDOM, NULL);

try {
XalanTransforme r theXalanTransfo rmer;
theXalanTransfo rmer.setErrorHa ndler(&xml_erro r);
theXalanTransfo rmer.transform( "xml_file.x ml",
L"questionaire_ retrieve_sheets .xsl", theFormatter);
}
catch (...) {
theDOM->release();
theDOM = NULL;
return 0;
}

int length = 0;

DOMNodeList* sheets = NULL;
sheets = theDOM->getElementsByT agName(std::wst ring(L"sheet"). c_str());

if (NULL == sheets)
return 0;

length = sheets->getLength();
for (int cnt = 0; cnt < length; cnt++) {
DOMNode* sheet = sheets->item(cnt);

XercesDocumentW rapper theXalanDoc(the DOM, true, true, true);
XercesWrapperNa vigator theNavigator(&t heXalanDoc);
XalanNode* theSheet = theXalanDoc.map Node(sheet);

XalanSourceTree DOMSupport theDOMSupport;
XalanDocumentPr efixResolver thePrefixResolv er(&theXalanDoc );
XPathEvaluator theEvaluator;

// OK, let's find the context node...
XalanNode* const theSeqNode =
theEvaluator.se lectSingleNode( theDOMSupport, theSheet, L"./seq",
thePrefixResolv er);
XalanNode::Node Type type = theSeqNode->getNodeType( );
XalanDOMString sheet_seq = theSeqNode->getNodeValue() ;

}
Thanks you in advance.
Jul 20 '05 #1
2 7133


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);

XercesDocumentW rapper theXalanDoc(the DOM, true, true, true);
XercesWrapperNa vigator theNavigator(&t heXalanDoc);
XalanNode* theSheet = theXalanDoc.map Node(sheet);

XalanSourceTree DOMSupport theDOMSupport;
XalanDocumentPr efixResolver thePrefixResolv er(&theXalanDoc );
XPathEvaluator theEvaluator;

// OK, let's find the context node...
XalanNode* const theSeqNode
=theEvaluator.s electSingleNode (theDOMSupport, theSheet, L"./seq",
thePrefixResolv er);
XalanNode::Node Type 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
selectSingleNod e) 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*******@yaho o.de> wrote in message news:<41******* *************** @newsread4.arco r-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
selectSingleNod e) 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
11553
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. thanks in advance, david ---------------
0
3091
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 them. Basically i am tryin to do simple tree transversale and get the node values out
9
5584
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, using the same HTML/JS it always returns no data (xmlhttp.responseText is null). When I try to get headers using Mozilla or display the http status code I get some obscure exception in the javascript console that I've given up on searching for an...
8
2371
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 ("categories2subcategories", dc1, dc2); ds.Relations.Add (dr1); dc1 always works fine. dc2 always returns null. There ARE records in
10
4590
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 zero-length string (always returns a zero-length string when used in a query expression)" **** How many records are there in FirstTable in which Product Is Null. SELECT COUNT(*) AS CountofNullProdcut
3
4084
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 has an anchor <a name="anchorname">...</a>). Doing this in Javascript is necessary in the presence of a dynamic HTML page having some hidden blocks. DHTML messes up the scroll position in Opera and Mozilla (but not IE) so I'm trying to fix it...
10
4275
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. The following statement returns the expected results: select case when NULL is null then 'SAME' else 'DIFFERENT' end from sysibm.sysdummy1; returns SAME.
3
9586
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 in an ASP page to read an incoming XML post request and respond to it. Although the XMLDOM object verifies the XML at a basic level, I want to make sure that the request is in the correct format (as per the specification I have to
3
12310
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) length string, an empty Field, or no value at all - so exactly what is Null? The purpose of this Topic is hopefully to explain what a Null Value is, discuss some peculiarities about Nulls, show how we can detect them, and finally, how to convert...
0
9589
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
10045
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...
0
9863
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
8870
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...
1
7408
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
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
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.