Re: [xml] patch: xmlTextReaderGetAttribute and xmlns support



Daniel Veillard wrote:

On Tue, Aug 16, 2005 at 05:55:32PM -0400, Rob Richards wrote:
Nope that one is fine. Havent implemented the xxAttributeNS functions yet.

 okidoc, applied and commited,
Here's the patch for xmlTextReaderGetAttributeNs and xmlTextReaderMoveToAttributeNs

Rob
Index: xmlreader.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/xmlreader.c,v
retrieving revision 1.125
diff -c -r1.125 xmlreader.c
*** xmlreader.c 17 Aug 2005 07:07:44 -0000      1.125
--- xmlreader.c 20 Aug 2005 15:07:32 -0000
***************
*** 2365,2370 ****
--- 2365,2373 ----
  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,2381 ****
--- 2379,2399 ----
      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,2631 ****
--- 2644,2651 ----
        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,2644 ****
        return(0);
      node = reader->node;
  
!     /*
!      * A priori reading http://www.w3.org/TR/REC-xml-names/ there is no
!      * namespace name associated to "xmlns"
!      */
      prop = node->properties;
      while (prop != NULL) {
        /*
--- 2655,2676 ----
        return(0);
      node = reader->node;
  
!     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) {
        /*


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]