1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-08-01 10:06:59 +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:
Daniel Veillard
2001-07-08 14:27:15 +00:00
parent 7583a59b5a
commit 0438375d2e
2 changed files with 40 additions and 30 deletions

View File

@ -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

15
xpath.c
View File

@ -4815,7 +4815,8 @@ 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) {
@ -4838,14 +4839,18 @@ xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs) {
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->
nodeTab[i]->name));
else { else {
char name[2000]; char name[2000];
snprintf(name, sizeof(name), "%s:%s", snprintf(name, sizeof(name), "%s:%s",
(char *) cur->nodesetval->nodeTab[i]->ns->prefix, (char *) cur->nodesetval->nodeTab[i]->ns->
prefix,
(char *) cur->nodesetval->nodeTab[i]->name); (char *) cur->nodesetval->nodeTab[i]->name);
name[sizeof(name) - 1] = 0; name[sizeof(name) - 1] = 0;
valuePush(ctxt, xmlXPathNewCString(name)); valuePush(ctxt, xmlXPathNewCString(name));