mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
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.
This commit is contained in:
@@ -59,6 +59,14 @@ Set contains 3 nodes:
|
|||||||
3 TEXT
|
3 TEXT
|
||||||
content=
|
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
|
Expression: /descendant::title
|
||||||
Object is a Node Set :
|
Object is a Node Set :
|
||||||
|
|||||||
@@ -5,5 +5,6 @@
|
|||||||
/child::EXAMPLE/child::head/child::title
|
/child::EXAMPLE/child::head/child::title
|
||||||
/child::EXAMPLE/child::head/child::title/child::text()
|
/child::EXAMPLE/child::head/child::title/child::text()
|
||||||
/child::EXAMPLE/child::head/node()
|
/child::EXAMPLE/child::head/node()
|
||||||
|
/child::EXAMPLE/attribute::prop1/descendant-or-self::node()
|
||||||
/descendant::title
|
/descendant::title
|
||||||
/descendant::p/ancestor::chapter
|
/descendant::p/ancestor::chapter
|
||||||
|
|||||||
14
xpath.c
14
xpath.c
@@ -7933,14 +7933,14 @@ xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
|
|||||||
xmlNodePtr
|
xmlNodePtr
|
||||||
xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
|
xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
|
||||||
if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
|
if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
|
||||||
if (cur == 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);
|
|
||||||
return(ctxt->context->node);
|
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));
|
return(xmlXPathNextDescendant(ctxt, cur));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user