mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-01 10:06:59 +03:00
- tree.[ch] parser.c xpath.c: fixed the problem of addressing
attributes within the XML-1.0 namespace Daniel
This commit is contained in:
@ -1,3 +1,8 @@
|
||||
Fri Feb 16 01:10:06 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||
|
||||
* tree.[ch] parser.c xpath.c: fixed the problem of addressing
|
||||
attributes within the XML-1.0 namespace
|
||||
|
||||
Thu Feb 15 16:53:20 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||
|
||||
* xpathInternals.h: exported a few axis functions
|
||||
|
@ -20,6 +20,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define XML_XML_NAMESPACE \
|
||||
(const xmlChar *) "http://www.w3.org/XML/1998/namespace"
|
||||
|
||||
/*
|
||||
* The different element types carried by an XML tree
|
||||
*
|
||||
|
2
parser.c
2
parser.c
@ -1473,10 +1473,12 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
|
||||
|
||||
*prefix = NULL;
|
||||
|
||||
#ifndef XML_XML_NAMESPACE
|
||||
/* xml: prefix is not really a namespace */
|
||||
if ((cur[0] == 'x') && (cur[1] == 'm') &&
|
||||
(cur[2] == 'l') && (cur[3] == ':'))
|
||||
return(xmlStrdup(name));
|
||||
#endif
|
||||
|
||||
/* nasty but valid */
|
||||
if (cur[0] == ':')
|
||||
|
39
tree.c
39
tree.c
@ -3615,6 +3615,26 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
|
||||
xmlNsPtr cur;
|
||||
|
||||
if (node == NULL) return(NULL);
|
||||
if ((nameSpace != NULL) &&
|
||||
(xmlStrEqual(nameSpace, (const xmlChar *)"xml"))) {
|
||||
if (doc->oldNs == NULL) {
|
||||
/*
|
||||
* Allocate a new Namespace and fill the fields.
|
||||
*/
|
||||
doc->oldNs = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
|
||||
if (doc->oldNs == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlSearchNsByHref : malloc failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
memset(doc->oldNs, 0, sizeof(xmlNs));
|
||||
doc->oldNs->type = XML_LOCAL_NAMESPACE;
|
||||
|
||||
doc->oldNs->href = xmlStrdup(XML_XML_NAMESPACE);
|
||||
doc->oldNs->prefix = xmlStrdup((const xmlChar *)"xml");
|
||||
}
|
||||
return(doc->oldNs);
|
||||
}
|
||||
while (node != NULL) {
|
||||
if ((node->type == XML_ENTITY_REF_NODE) ||
|
||||
(node->type == XML_ENTITY_NODE) ||
|
||||
@ -3654,6 +3674,25 @@ xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar *href) {
|
||||
xmlNodePtr orig = node;
|
||||
|
||||
if ((node == NULL) || (href == NULL)) return(NULL);
|
||||
if (xmlStrEqual(href, XML_XML_NAMESPACE)) {
|
||||
if (doc->oldNs == NULL) {
|
||||
/*
|
||||
* Allocate a new Namespace and fill the fields.
|
||||
*/
|
||||
doc->oldNs = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
|
||||
if (doc->oldNs == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlSearchNsByHref : malloc failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
memset(doc->oldNs, 0, sizeof(xmlNs));
|
||||
doc->oldNs->type = XML_LOCAL_NAMESPACE;
|
||||
|
||||
doc->oldNs->href = xmlStrdup(XML_XML_NAMESPACE);
|
||||
doc->oldNs->prefix = xmlStrdup((const xmlChar *)"xml");
|
||||
}
|
||||
return(doc->oldNs);
|
||||
}
|
||||
while (node != NULL) {
|
||||
cur = node->nsDef;
|
||||
while (cur != NULL) {
|
||||
|
3
tree.h
3
tree.h
@ -20,6 +20,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define XML_XML_NAMESPACE \
|
||||
(const xmlChar *) "http://www.w3.org/XML/1998/namespace"
|
||||
|
||||
/*
|
||||
* The different element types carried by an XML tree
|
||||
*
|
||||
|
24
xpath.c
24
xpath.c
@ -1344,6 +1344,12 @@ xmlXPathNsLookup(xmlXPathContextPtr ctxt, const xmlChar *prefix) {
|
||||
return(NULL);
|
||||
if (prefix == NULL)
|
||||
return(NULL);
|
||||
|
||||
#ifdef XML_XML_NAMESPACE
|
||||
if (xmlStrEqual(prefix, (const xmlChar *) "xml"))
|
||||
return(XML_XML_NAMESPACE);
|
||||
#endif
|
||||
|
||||
if (ctxt->nsHash == NULL)
|
||||
return(NULL);
|
||||
|
||||
@ -3289,10 +3295,24 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, xmlXPathAxisVal axis,
|
||||
case XML_ATTRIBUTE_NODE: {
|
||||
xmlAttrPtr attr = (xmlAttrPtr) cur;
|
||||
if (xmlStrEqual(name, attr->name)) {
|
||||
if (prefix == NULL) {
|
||||
if ((attr->ns == NULL) ||
|
||||
(attr->ns->prefix == NULL)) {
|
||||
#ifdef DEBUG_STEP
|
||||
n++;
|
||||
n++;
|
||||
#endif
|
||||
addNode(ret, cur);
|
||||
addNode(ret, attr);
|
||||
}
|
||||
} else {
|
||||
if ((attr->ns != NULL) &&
|
||||
(xmlStrEqual(prefix,
|
||||
attr->ns->href))) {
|
||||
#ifdef DEBUG_STEP
|
||||
n++;
|
||||
#endif
|
||||
addNode(ret, attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user