Re: [xml] xmlwriter, invalid StartElement



C# will close off the attribute and start a new element. libxml on the other hand is putting the element as the attribute value.

Attached is a patch to check for the attribute state in xmlTextWriterStartElement as well as fix a ns reversal from last patch for xmlTextWriterEndAttribute.

Rob

Pierre Joye wrote:

Bonjour Daniel,

On Wed, 23 Feb 2005 05:08:02 -0500, Daniel Veillard <veillard redhat com> wrote:
 I don't know how C# xmlReader reacts in those case, could someone
try and provide feedback ?

Ah I did not know that xmlReader is based on the c# one (for the
concept), I will give it a try later.
I asked some php people around (I'm helping Rob Richards with his
xmlWriter php extension), seems like getting an error (-1) is what
they all expect.
Index: xmlwriter.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/xmlwriter.c,v
retrieving revision 1.28
diff -c -r1.28 xmlwriter.c
*** xmlwriter.c 21 Feb 2005 13:49:46 -0000      1.28
--- xmlwriter.c 23 Feb 2005 13:35:58 -0000
***************
*** 936,941 ****
--- 936,947 ----
                      return -1;
                  case XML_TEXTWRITER_NONE:
                      break;
+                               case XML_TEXTWRITER_ATTRIBUTE:
+                                       count = xmlTextWriterEndAttribute(writer);
+                                       if (count < 0)
+                                               return -1;
+                                       sum += count;
+                                       /* fallthrough */
                  case XML_TEXTWRITER_NAME:
                      count = xmlOutputBufferWriteString(writer->out, ">");
                      if (count < 0)
***************
*** 1839,1846 ****
                  np = (xmlTextWriterNsStackEntry *) xmlLinkGetData(lk);
  
                if (np != 0) {
!                   namespaceURI = xmlStrdup(np->prefix);
!                   prefix = xmlStrdup(np->uri);
                }
  
                xmlListPopFront(writer->nsstack);
--- 1845,1852 ----
                  np = (xmlTextWriterNsStackEntry *) xmlLinkGetData(lk);
  
                if (np != 0) {
!                   namespaceURI = xmlStrdup(np->uri);
!                   prefix = xmlStrdup(np->prefix);
                }
  
                xmlListPopFront(writer->nsstack);


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