Re: [xml] xml:space and xml:lang problem



Added XML_WAR_SPACE_VALUE to xmlParserErrors enum, changed to warning in both functions and using pointer comparison now.

Rob

Daniel Veillard wrote:

On Wed, Jun 08, 2005 at 04:53:02PM -0400, Rob Richards wrote:
One thing to note about the patch however is that the the value for xml:space will be enforced again. Currently, its value could be anything since the checks are bypassed, but with the patch, the behavior reverts back to how it was in 2.5.x where only "default" or "preserve" are allowed. Everything else results in an xmlFatalErrMsgStr.

 which is also something we clarified at W3C, it should not be a
fatal error, but a warning in that case.

Would you mind regenerating a new patch with the couple of ajustments ?
   thanks !

Daniel

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    8 Jun 2005 21:35:31 -0000
***************
*** 6747,6755 ****
        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);
        }
      }
  
--- 6747,6755 ----
        else if (xmlStrEqual(val, BAD_CAST "preserve"))
            *(ctxt->space) = 1;
        else {
!               xmlWarningMsg(ctxt, XML_WAR_SPACE_VALUE,
  "Invalid value \"%s\" for xml:space : \"default\" or \"preserve\" expected\n",
!                                  val, NULL);
        }
      }
  
***************
*** 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 (*prefix == ctxt->str_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 {
!                               xmlWarningMsg(ctxt, XML_WAR_SPACE_VALUE,
  "Invalid value \"%s\" for xml:space : \"default\" or \"preserve\" expected\n",
!                                  internal_val, NULL);
!                       }
!               }
!               if (internal_val) {
!                       xmlFree(internal_val);
!               }
        }
  
      *value = val;
      return(name);


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