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. 2 7110
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/
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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.
...
|
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...
|
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,...
|
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...
|
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...
| |
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...
|
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. ...
|
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...
|
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...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
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...
|
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...
|
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...
|
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...
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |