applied another patch from Rob Richards to fix xmlTextReaderGetAttributeNs
* xmlreader.c: applied another patch from Rob Richards to fix
xmlTextReaderGetAttributeNs and xmlTextReaderMoveToAttributeNs
Daniel
diff --git a/xmlreader.c b/xmlreader.c
index b1bac08..5fdf3a5 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -2365,6 +2365,9 @@
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 @@
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 @@
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 @@
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) {
/*