1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00

applied another patch from Rob Richards to fix xmlTextReaderGetAttributeNs

* xmlreader.c: applied another patch from Rob Richards to fix
  xmlTextReaderGetAttributeNs and xmlTextReaderMoveToAttributeNs
Daniel
This commit is contained in:
Daniel Veillard 2005-08-20 21:14:28 +00:00
parent 3c40e61b7e
commit 45b97e72d1
2 changed files with 41 additions and 4 deletions

View File

@ -1,3 +1,8 @@
Sat Aug 20 23:13:27 CEST 2005 Daniel Veillard <daniel@veillard.com>
* xmlreader.c: applied another patch from Rob Richards to fix
xmlTextReaderGetAttributeNs and xmlTextReaderMoveToAttributeNs
Wed Aug 17 09:06:33 CEST 2005 Daniel Veillard <daniel@veillard.com>
* xmlreader.c: applied patch from Rob Richards to fix

View File

@ -2365,6 +2365,9 @@ xmlTextReaderGetAttribute(xmlTextReaderPtr reader, const xmlChar *name) {
xmlChar *
xmlTextReaderGetAttributeNs(xmlTextReaderPtr reader, const xmlChar *localName,
const xmlChar *namespaceURI) {
xmlChar *prefix = NULL;
xmlNsPtr ns;
if ((reader == NULL) || (localName == NULL))
return(NULL);
if (reader->node == NULL)
@ -2376,6 +2379,21 @@ xmlTextReaderGetAttributeNs(xmlTextReaderPtr reader, const xmlChar *localName,
if (reader->node->type != XML_ELEMENT_NODE)
return(NULL);
if (xmlStrEqual(namespaceURI, BAD_CAST "http://www.w3.org/2000/xmlns/")) {
if (! xmlStrEqual(localName, BAD_CAST "xmlns")) {
prefix = BAD_CAST localName;
}
ns = reader->node->nsDef;
while (ns != NULL) {
if ((prefix == NULL && ns->prefix == NULL) ||
((ns->prefix != NULL) && (xmlStrEqual(ns->prefix, localName)))) {
return xmlStrdup(ns->href);
}
ns = ns->next;
}
return NULL;
}
return(xmlGetNsProp(reader->node, localName, namespaceURI));
}
@ -2626,6 +2644,8 @@ xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader,
const xmlChar *localName, const xmlChar *namespaceURI) {
xmlAttrPtr prop;
xmlNodePtr node;
xmlNsPtr ns;
xmlChar *prefix = NULL;
if ((reader == NULL) || (localName == NULL) || (namespaceURI == NULL))
return(-1);
@ -2635,10 +2655,22 @@ xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader,
return(0);
node = reader->node;
/*
* A priori reading http://www.w3.org/TR/REC-xml-names/ there is no
* namespace name associated to "xmlns"
*/
if (xmlStrEqual(namespaceURI, BAD_CAST "http://www.w3.org/2000/xmlns/")) {
if (! xmlStrEqual(localName, BAD_CAST "xmlns")) {
prefix = BAD_CAST localName;
}
ns = reader->node->nsDef;
while (ns != NULL) {
if ((prefix == NULL && ns->prefix == NULL) ||
((ns->prefix != NULL) && (xmlStrEqual(ns->prefix, localName)))) {
reader->curnode = (xmlNodePtr) ns;
return(1);
}
ns = ns->next;
}
return(0);
}
prop = node->properties;
while (prop != NULL) {
/*