aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2015-03-08 16:05:26 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2015-03-08 16:25:52 +0100
commitf6aaabce85baf48d622cb4686df810fdba3db073 (patch)
tree465ce86d5a7132bfd863cede8964f3930ec2cff0
parent620a70615e68b30db1a80a993180a41dc24f12b9 (diff)
downloadandroid_external_libxml2-f6aaabce85baf48d622cb4686df810fdba3db073.tar.gz
android_external_libxml2-f6aaabce85baf48d622cb4686df810fdba3db073.tar.bz2
android_external_libxml2-f6aaabce85baf48d622cb4686df810fdba3db073.zip
Allow attributes on descendant-or-self axis
If the context node is an attribute, the attribute itself is on the descendant-or-self axis. The principal node type of this axis is element, so the only node test that can return the attribute is "node()". In other words, "@attr/descendant-or-self::node()" is equivalent to "@attr". This matches the behavior of Saxon-CE.
-rw-r--r--result/XPath/tests/simplebase8
-rw-r--r--test/XPath/tests/simplebase1
-rw-r--r--xpath.c14
3 files changed, 16 insertions, 7 deletions
diff --git a/result/XPath/tests/simplebase b/result/XPath/tests/simplebase
index 38fa1449..980d18ef 100644
--- a/result/XPath/tests/simplebase
+++ b/result/XPath/tests/simplebase
@@ -60,6 +60,14 @@ Set contains 3 nodes:
content=
========================
+Expression: /child::EXAMPLE/attribute::prop1/descendant-or-self::node()
+Object is a Node Set :
+Set contains 1 nodes:
+1 ATTRIBUTE prop1
+ TEXT
+ content=gnome is great
+
+========================
Expression: /descendant::title
Object is a Node Set :
Set contains 2 nodes:
diff --git a/test/XPath/tests/simplebase b/test/XPath/tests/simplebase
index 7e4203af..9a1476e6 100644
--- a/test/XPath/tests/simplebase
+++ b/test/XPath/tests/simplebase
@@ -5,5 +5,6 @@
/child::EXAMPLE/child::head/child::title
/child::EXAMPLE/child::head/child::title/child::text()
/child::EXAMPLE/child::head/node()
+/child::EXAMPLE/attribute::prop1/descendant-or-self::node()
/descendant::title
/descendant::p/ancestor::chapter
diff --git a/xpath.c b/xpath.c
index dc41ce6b..ffd2a489 100644
--- a/xpath.c
+++ b/xpath.c
@@ -7933,14 +7933,14 @@ xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
xmlNodePtr
xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
- if (cur == NULL) {
- if (ctxt->context->node == NULL)
- return(NULL);
- if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
- (ctxt->context->node->type == XML_NAMESPACE_DECL))
- return(NULL);
+ if (cur == NULL)
return(ctxt->context->node);
- }
+
+ if (ctxt->context->node == NULL)
+ return(NULL);
+ if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
+ (ctxt->context->node->type == XML_NAMESPACE_DECL))
+ return(NULL);
return(xmlXPathNextDescendant(ctxt, cur));
}