Commit 0438375d authored by Daniel Veillard's avatar Daniel Veillard

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
parent 7583a59b
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>
* SAX.c parser.c testXPath.c xpath.c: trying to fix #56948, this
......
......@@ -4815,47 +4815,52 @@ xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* returned.
*/
static void
xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs)
{
xmlXPathObjectPtr cur;
if (nargs == 0) {
valuePush(ctxt, xmlXPathNewNodeSet(ctxt->context->node));
nargs = 1;
valuePush(ctxt, xmlXPathNewNodeSet(ctxt->context->node));
nargs = 1;
}
CHECK_ARITY(1);
if ((ctxt->value == NULL) ||
((ctxt->value->type != XPATH_NODESET) &&
(ctxt->value->type != XPATH_XSLT_TREE)))
XP_ERROR(XPATH_INVALID_TYPE);
if ((ctxt->value == NULL) ||
((ctxt->value->type != XPATH_NODESET) &&
(ctxt->value->type != XPATH_XSLT_TREE)))
XP_ERROR(XPATH_INVALID_TYPE);
cur = valuePop(ctxt);
if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr == 0)) {
valuePush(ctxt, xmlXPathNewCString(""));
valuePush(ctxt, xmlXPathNewCString(""));
} 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) {
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
if (cur->nodesetval->nodeTab[i]->ns == NULL)
valuePush(ctxt, xmlXPathNewString(
cur->nodesetval->nodeTab[i]->name));
else {
char name[2000];
snprintf(name, sizeof(name), "%s:%s",
(char *) cur->nodesetval->nodeTab[i]->ns->prefix,
(char *) cur->nodesetval->nodeTab[i]->name);
name[sizeof(name) - 1] = 0;
valuePush(ctxt, xmlXPathNewCString(name));
}
break;
default:
valuePush(ctxt,
xmlXPathNewNodeSet(cur->nodesetval->nodeTab[i]));
xmlXPathLocalNameFunction(ctxt, 1);
}
switch (cur->nodesetval->nodeTab[i]->type) {
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
if ((cur->nodesetval->nodeTab[i]->ns == NULL) ||
(cur->nodesetval->nodeTab[i]->ns->prefix == NULL))
valuePush(ctxt,
xmlXPathNewString(cur->nodesetval->
nodeTab[i]->name));
else {
char name[2000];
snprintf(name, sizeof(name), "%s:%s",
(char *) cur->nodesetval->nodeTab[i]->ns->
prefix,
(char *) cur->nodesetval->nodeTab[i]->name);
name[sizeof(name) - 1] = 0;
valuePush(ctxt, xmlXPathNewCString(name));
}
break;
default:
valuePush(ctxt,
xmlXPathNewNodeSet(cur->nodesetval->nodeTab[i]));
xmlXPathLocalNameFunction(ctxt, 1);
}
}
xmlXPathFreeObject(cur);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment