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

[xml] xml:space and xml:lang problem



Looks like xml:space is broken as of 2.6.0 with sax2
Running xmllint --noblanks on the following:
<doc>
  <e1>
     <e2 xml:space="preserve">
        <e3 id="E3"/>
     </e2>
  </e1>
</doc>

ignores the preserve while it doesn't in 2.5.x (different function call)
xml:lang has the same issue

Attached is the patch I'm using for it - moved some things around as well.

Rob


Index: parser.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/parser.c,v
retrieving revision 1.424
diff -c -r1.424 parser.c
*** parser.c	29 Apr 2005 10:04:43 -0000	1.424
--- parser.c	2 Jun 2005 13:06:41 -0000
***************
*** 7414,7420 ****
                     const xmlChar **prefix, xmlChar **value,
  		   int *len, int *alloc) {
      const xmlChar *name;
!     xmlChar *val;
      int normalize = 0;
  
      *value = NULL;
--- 7414,7420 ----
                     const xmlChar **prefix, xmlChar **value,
  		   int *len, int *alloc) {
      const xmlChar *name;
!     xmlChar *val, *internal_val = NULL;
      int normalize = 0;
  
      *value = NULL;
***************
*** 7452,7484 ****
  	return(NULL);
      }
  
!     /*
!      * Check that xml:lang conforms to the specification
!      * No more registered as an error, just generate a warning now
!      * since this was deprecated in XML second edition
!      */
!     if ((ctxt->pedantic) && (xmlStrEqual(name, BAD_CAST "xml:lang"))) {
! 	if (!xmlCheckLanguageID(val)) {
! 	    xmlWarningMsg(ctxt, XML_WAR_LANG_VALUE,
! 		          "Malformed value for xml:lang : %s\n",
! 			  val, NULL);
! 	}
!     }
! 
!     /*
!      * Check that xml:space conforms to the specification
!      */
!     if (xmlStrEqual(name, BAD_CAST "xml:space")) {
! 	if (xmlStrEqual(val, BAD_CAST "default"))
! 	    *(ctxt->space) = 0;
! 	else if (xmlStrEqual(val, BAD_CAST "preserve"))
! 	    *(ctxt->space) = 1;
! 	else {
! 	    xmlFatalErrMsgStr(ctxt, XML_ERR_ATTRIBUTE_WITHOUT_VALUE,
  "Invalid value \"%s\" for xml:space : \"default\" or \"preserve\" expected\n",
!                                  val);
  	}
-     }
  
      *value = val;
      return(name);
--- 7452,7491 ----
  	return(NULL);
      }
  
! 	if (xmlStrEqual(*prefix, BAD_CAST "xml")) {
! 		/*
! 		 * Check that xml:lang conforms to the specification
! 		 * No more registered as an error, just generate a warning now
! 		 * since this was deprecated in XML second edition
! 		 */
! 		if ((ctxt->pedantic) && (xmlStrEqual(name, BAD_CAST "lang"))) {
! 			internal_val = xmlStrndup(val, *len);
! 			if (!xmlCheckLanguageID(internal_val)) {
! 				xmlWarningMsg(ctxt, XML_WAR_LANG_VALUE,
! 						  "Malformed value for xml:lang : %s\n",
! 					  internal_val, NULL);
! 			}
! 		}
! 
! 		/*
! 		 * Check that xml:space conforms to the specification
! 		 */
! 		if (xmlStrEqual(name, BAD_CAST "space")) {
! 			internal_val = xmlStrndup(val, *len);
! 			if (xmlStrEqual(internal_val, BAD_CAST "default"))
! 				*(ctxt->space) = 0;
! 			else if (xmlStrEqual(internal_val, BAD_CAST "preserve"))
! 				*(ctxt->space) = 1;
! 			else {
! 				xmlFatalErrMsgStr(ctxt, XML_ERR_ATTRIBUTE_WITHOUT_VALUE,
  "Invalid value \"%s\" for xml:space : \"default\" or \"preserve\" expected\n",
!                                  internal_val);
! 			}
! 		}
! 		if (internal_val) {
! 			xmlFree(internal_val);
! 		}
  	}
  
      *value = val;
      return(name);


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