My favorites | Sign in
Project Home
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 47: nodesForXPath:error method of CXMLNode does not support xpath expressions like 'concat(...)'
2 people starred this issue and may be notified of changes. Back to list
Status:  Invalid
Owner:  ----
Closed:  Feb 2009


 
Reported by quentin....@gmail.com, Feb 2, 2009
What steps will reproduce the problem?
1.call nodesForXPath:error: with an xpath expression like
"concat('http://twitter.com/', user/screen_name, '/statuses/', id)"
2. Returned array is empty, although this xpath expression is correct

What is the expected output? What do you see instead?

1    - (NSArray *)nodesForXPath:(NSString *)xpath error:(NSError **)error
2    {
3    NSAssert(_node != NULL, @"TODO");
4
5    NSArray *theResult = NULL;
6 
7    CXMLNode *theRootDocument = [self rootDocument];
8    xmlXPathContextPtr theXPathContext =
xmlXPathNewContext((xmlDocPtr)theRootDocument->_node);
9    theXPathContext->node = _node;
10
11   // TODO considering putting xmlChar <-> UTF8 into a NSString category
xmlXPathObjectPtr theXPathObject = xmlXPathEvalExpression((const xmlChar
*)[xpath UTF8String], theXPathContext);
12   if (xmlXPathNodeSetIsEmpty(theXPathObject->nodesetval))
13      	theResult = [NSArray array]; // TODO better to return NULL?
14   else
15	{
16	NSMutableArray *theArray = [NSMutableArray array];
17	int N;
18	for (N = 0; N < theXPathObject->nodesetval->nodeNr; N++)
19		{
20		xmlNodePtr theNode = theXPathObject->nodesetval->nodeTab[N];
21		[theArray addObject:[CXMLNode nodeWithLibXMLNode:theNode]];
22		}
23		
24	theResult = theArray;
25	}
26
27   xmlXPathFreeObject(theXPathObject);
28   xmlXPathFreeContext(theXPathContext);
29   return(theResult);
30   }

@l.11: xpath expression is evaluated and result is:
(gdb) print *theXPathObject
$4 = {
  type = XPATH_STRING, 
  nodesetval = 0x0, 
  boolval = 0, 
  floatval = 0, 
  stringval = 0x142d50 "http://twitter.com/bububax/statuses/1170320948", 
  user = 0x0, 
  index = 0, 
  user2 = 0x0, 
  index2 = 0
}

@l.12: nodesetval is tested and as it is null, we ignore stringval value
and concider that there is no result.

What version of the product are you using? On what operating system?
Do not know.

Please provide any additional information below.


Feb 28, 2009
Project Member #1 jwight
Please provide sample code & sample data.
Status: Invalid

Powered by Google Project Hosting