| OLD | NEW |
| 1 /* | 1 /* |
| 2 * xpath.c: XML Path Language implementation | 2 * xpath.c: XML Path Language implementation |
| 3 * XPath is a language for addressing parts of an XML document, | 3 * XPath is a language for addressing parts of an XML document, |
| 4 * designed to be used by both XSLT and XPointer | 4 * designed to be used by both XSLT and XPointer |
| 5 *f | 5 *f |
| 6 * Reference: W3C Recommendation 16 November 1999 | 6 * Reference: W3C Recommendation 16 November 1999 |
| 7 * http://www.w3.org/TR/1999/REC-xpath-19991116 | 7 * http://www.w3.org/TR/1999/REC-xpath-19991116 |
| 8 * Public reference: | 8 * Public reference: |
| 9 * http://www.w3.org/TR/xpath | 9 * http://www.w3.org/TR/xpath |
| 10 * | 10 * |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 | 354 |
| 355 turtle_comparison: | 355 turtle_comparison: |
| 356 | 356 |
| 357 if (node1 == node2->prev) | 357 if (node1 == node2->prev) |
| 358 return(1); | 358 return(1); |
| 359 if (node1 == node2->next) | 359 if (node1 == node2->next) |
| 360 return(-1); | 360 return(-1); |
| 361 /* | 361 /* |
| 362 * compute depth to root | 362 * compute depth to root |
| 363 */ | 363 */ |
| 364 for (depth2 = 0, cur = node2;cur->parent != NULL;cur = cur->parent) { | 364 for (depth2 = 0, cur = node2; cur->parent != NULL; cur = cur->parent) { |
| 365 » if (cur == node1) | 365 » if (cur->parent == node1) |
| 366 return(1); | 366 return(1); |
| 367 depth2++; | 367 depth2++; |
| 368 } | 368 } |
| 369 root = cur; | 369 root = cur; |
| 370 for (depth1 = 0, cur = node1;cur->parent != NULL;cur = cur->parent) { | 370 for (depth1 = 0, cur = node1; cur->parent != NULL; cur = cur->parent) { |
| 371 » if (cur == node2) | 371 » if (cur->parent == node2) |
| 372 return(-1); | 372 return(-1); |
| 373 depth1++; | 373 depth1++; |
| 374 } | 374 } |
| 375 /* | 375 /* |
| 376 * Distinct document (or distinct entities :-( ) case. | 376 * Distinct document (or distinct entities :-( ) case. |
| 377 */ | 377 */ |
| 378 if (root != cur) { | 378 if (root != cur) { |
| 379 return(-2); | 379 return(-2); |
| 380 } | 380 } |
| 381 /* | 381 /* |
| (...skipping 7545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7927 * the descendant-or-self axis contains the context node and the descendants | 7927 * the descendant-or-self axis contains the context node and the descendants |
| 7928 * of the context node in document order; thus the context node is the first | 7928 * of the context node in document order; thus the context node is the first |
| 7929 * node on the axis, and the first child of the context node is the second node | 7929 * node on the axis, and the first child of the context node is the second node |
| 7930 * on the axis | 7930 * on the axis |
| 7931 * | 7931 * |
| 7932 * Returns the next element following that axis | 7932 * Returns the next element following that axis |
| 7933 */ | 7933 */ |
| 7934 xmlNodePtr | 7934 xmlNodePtr |
| 7935 xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { | 7935 xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { |
| 7936 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); | 7936 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); |
| 7937 if (cur == NULL) { | 7937 if (cur == NULL) |
| 7938 » if (ctxt->context->node == NULL) | |
| 7939 » return(NULL); | |
| 7940 » if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) || | |
| 7941 » (ctxt->context->node->type == XML_NAMESPACE_DECL)) | |
| 7942 » return(NULL); | |
| 7943 return(ctxt->context->node); | 7938 return(ctxt->context->node); |
| 7944 } | 7939 |
| 7940 if (ctxt->context->node == NULL) |
| 7941 return(NULL); |
| 7942 if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) || |
| 7943 (ctxt->context->node->type == XML_NAMESPACE_DECL)) |
| 7944 return(NULL); |
| 7945 | 7945 |
| 7946 return(xmlXPathNextDescendant(ctxt, cur)); | 7946 return(xmlXPathNextDescendant(ctxt, cur)); |
| 7947 } | 7947 } |
| 7948 | 7948 |
| 7949 /** | 7949 /** |
| 7950 * xmlXPathNextParent: | 7950 * xmlXPathNextParent: |
| 7951 * @ctxt: the XPath Parser context | 7951 * @ctxt: the XPath Parser context |
| 7952 * @cur: the current node in the traversal | 7952 * @cur: the current node in the traversal |
| 7953 * | 7953 * |
| 7954 * Traversal function for the "parent" direction | 7954 * Traversal function for the "parent" direction |
| (...skipping 7434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15389 xmlXPathTranslateFunction); | 15389 xmlXPathTranslateFunction); |
| 15390 | 15390 |
| 15391 xmlXPathRegisterFuncNS(ctxt, (const xmlChar *)"escape-uri", | 15391 xmlXPathRegisterFuncNS(ctxt, (const xmlChar *)"escape-uri", |
| 15392 (const xmlChar *)"http://www.w3.org/2002/08/xquery-functions", | 15392 (const xmlChar *)"http://www.w3.org/2002/08/xquery-functions", |
| 15393 xmlXPathEscapeUriFunction); | 15393 xmlXPathEscapeUriFunction); |
| 15394 } | 15394 } |
| 15395 | 15395 |
| 15396 #endif /* LIBXML_XPATH_ENABLED */ | 15396 #endif /* LIBXML_XPATH_ENABLED */ |
| 15397 #define bottom_xpath | 15397 #define bottom_xpath |
| 15398 #include "elfgcchack.h" | 15398 #include "elfgcchack.h" |
| OLD | NEW |