mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-30 22:43:14 +03:00
fix the name() bug for elements in the default namespace reported by
* xpath.c: fix the name() bug for elements in the default namespace reported by Charlie Bozeman Daniel
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
Sun Jul 8 16:26:00 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
|
* xpath.c: fix the name() bug for elements in the default
|
||||||
|
namespace reported by Charlie Bozeman
|
||||||
|
|
||||||
Sun Jul 8 15:11:05 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
Sun Jul 8 15:11:05 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
* SAX.c parser.c testXPath.c xpath.c: trying to fix #56948, this
|
* SAX.c parser.c testXPath.c xpath.c: trying to fix #56948, this
|
||||||
|
65
xpath.c
65
xpath.c
@ -4815,47 +4815,52 @@ xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
|||||||
* returned.
|
* returned.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs)
|
||||||
|
{
|
||||||
xmlXPathObjectPtr cur;
|
xmlXPathObjectPtr cur;
|
||||||
|
|
||||||
if (nargs == 0) {
|
if (nargs == 0) {
|
||||||
valuePush(ctxt, xmlXPathNewNodeSet(ctxt->context->node));
|
valuePush(ctxt, xmlXPathNewNodeSet(ctxt->context->node));
|
||||||
nargs = 1;
|
nargs = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_ARITY(1);
|
CHECK_ARITY(1);
|
||||||
if ((ctxt->value == NULL) ||
|
if ((ctxt->value == NULL) ||
|
||||||
((ctxt->value->type != XPATH_NODESET) &&
|
((ctxt->value->type != XPATH_NODESET) &&
|
||||||
(ctxt->value->type != XPATH_XSLT_TREE)))
|
(ctxt->value->type != XPATH_XSLT_TREE)))
|
||||||
XP_ERROR(XPATH_INVALID_TYPE);
|
XP_ERROR(XPATH_INVALID_TYPE);
|
||||||
cur = valuePop(ctxt);
|
cur = valuePop(ctxt);
|
||||||
|
|
||||||
if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr == 0)) {
|
if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr == 0)) {
|
||||||
valuePush(ctxt, xmlXPathNewCString(""));
|
valuePush(ctxt, xmlXPathNewCString(""));
|
||||||
} else {
|
} else {
|
||||||
int i = 0; /* Should be first in document order !!!!! */
|
int i = 0; /* Should be first in document order !!!!! */
|
||||||
|
|
||||||
switch (cur->nodesetval->nodeTab[i]->type) {
|
switch (cur->nodesetval->nodeTab[i]->type) {
|
||||||
case XML_ELEMENT_NODE:
|
case XML_ELEMENT_NODE:
|
||||||
case XML_ATTRIBUTE_NODE:
|
case XML_ATTRIBUTE_NODE:
|
||||||
if (cur->nodesetval->nodeTab[i]->ns == NULL)
|
if ((cur->nodesetval->nodeTab[i]->ns == NULL) ||
|
||||||
valuePush(ctxt, xmlXPathNewString(
|
(cur->nodesetval->nodeTab[i]->ns->prefix == NULL))
|
||||||
cur->nodesetval->nodeTab[i]->name));
|
valuePush(ctxt,
|
||||||
|
xmlXPathNewString(cur->nodesetval->
|
||||||
else {
|
nodeTab[i]->name));
|
||||||
char name[2000];
|
|
||||||
snprintf(name, sizeof(name), "%s:%s",
|
else {
|
||||||
(char *) cur->nodesetval->nodeTab[i]->ns->prefix,
|
char name[2000];
|
||||||
(char *) cur->nodesetval->nodeTab[i]->name);
|
|
||||||
name[sizeof(name) - 1] = 0;
|
snprintf(name, sizeof(name), "%s:%s",
|
||||||
valuePush(ctxt, xmlXPathNewCString(name));
|
(char *) cur->nodesetval->nodeTab[i]->ns->
|
||||||
}
|
prefix,
|
||||||
break;
|
(char *) cur->nodesetval->nodeTab[i]->name);
|
||||||
default:
|
name[sizeof(name) - 1] = 0;
|
||||||
valuePush(ctxt,
|
valuePush(ctxt, xmlXPathNewCString(name));
|
||||||
xmlXPathNewNodeSet(cur->nodesetval->nodeTab[i]));
|
}
|
||||||
xmlXPathLocalNameFunction(ctxt, 1);
|
break;
|
||||||
}
|
default:
|
||||||
|
valuePush(ctxt,
|
||||||
|
xmlXPathNewNodeSet(cur->nodesetval->nodeTab[i]));
|
||||||
|
xmlXPathLocalNameFunction(ctxt, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
xmlXPathFreeObject(cur);
|
xmlXPathFreeObject(cur);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user