From 669adfcd3af5dfda873b10119d44202a7450bb20 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Sat, 29 May 2004 20:12:46 +0000 Subject: [PATCH] applied a patch from Charles Bozeman fixing a side effect in date handling * test/schemas/date_0.xml xmlschemastypes.c: applied a patch from Charles Bozeman fixing a side effect in date handling Daniel --- ChangeLog | 5 + doc/FAQ.html | 3 +- doc/index.html | 362 ++++++++++------------------------------ test/schemas/date_0.xml | 1 + xmlschemastypes.c | 60 ++++--- 5 files changed, 135 insertions(+), 296 deletions(-) diff --git a/ChangeLog b/ChangeLog index 14b70a31..6be3f42f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat May 29 21:35:52 CEST 2004 Daniel Veillard + + * test/schemas/date_0.xml xmlschemastypes.c: applied a patch from + Charles Bozeman fixing a side effect in date handling + Thu May 27 19:47:48 MDT 2004 John Fleck * doc/tutorial/xmltutorial.xml fix lack of cast in Xpath example diff --git a/doc/FAQ.html b/doc/FAQ.html index 39f6d7ab..c8b7330a 100644 --- a/doc/FAQ.html +++ b/doc/FAQ.html @@ -217,7 +217,8 @@ pnode=pxmlDoc->children->children;

Website: http://pmade.org/pjones/software/xmlwrapp/

- --> + --> +
  • How to validate a document a posteriori ?

    It is possible to validate documents which had not been validated at initial parsing time or documents which have been built from scratch diff --git a/doc/index.html b/doc/index.html index 1ef7dc90..0bb28733 100644 --- a/doc/index.html +++ b/doc/index.html @@ -12,8 +12,7 @@ H2 {font-family: Verdana,Arial,Helvetica} H3 {font-family: Verdana,Arial,Helvetica} A:link, A:visited, A:active { text-decoration: underline } - The XML C parser and toolkit of Gnome - + The XML C parser and toolkit of Gnome @@ -46,10 +45,8 @@ A:link, A:visited, A:active { text-decoration: underline }
    -

    The XML C parser and toolkit of Gnome -

    -

    libxml -

    +

    The XML C parser and toolkit of Gnome

    +

    libxml

    @@ -72,8 +69,7 @@ A:link, A:visited, A:active { text-decoration: underline }

    - Main Menu - + Main Menu
    @@ -85,80 +81,61 @@ A:link, A:visited, A:active { text-decoration: underline } @@ -168,8 +145,7 @@ A:link, A:visited, A:active { text-decoration: underline }
    - Related links - + Related links
    @@ -177,44 +153,34 @@ A:link, A:visited, A:active { text-decoration: underline } @@ -236,227 +202,77 @@ A:link, A:visited, A:active { text-decoration: underline }

    "Programming -with libxml2 is like the thrilling embrace of an exotic stranger." - Mark -Pilgrim - -

    +with libxml2 is like the thrilling embrace of an exotic stranger." Mark +Pilgrim

    Libxml2 is the XML C parser and toolkit developed for the Gnome project (but usable outside of the Gnome platform), it is free software available -under the - MIT -License - -. XML itself is a metalanguage to design markup languages, i.e. +under the MIT +License. XML itself is a metalanguage to design markup languages, i.e. text language where semantic and structure are added to the content using extra "markup" information enclosed between angle brackets. HTML is the most -well-known markup language. Though the library is written in C - a variety of language bindings - - make it available in -other environments. -

    +well-known markup language. Though the library is written in C a variety of language bindings make it available in +other environments.

    Libxml2 is known to be very portable, the library should build and work without serious troubles on a variety of systems (Linux, Unix, Windows, -CygWin, MacOS, MacOS X, RISC Os, OS/2, VMS, QNX, MVS, ...) -

    +CygWin, MacOS, MacOS X, RISC Os, OS/2, VMS, QNX, MVS, ...)

    Libxml2 implements a number of existing standards related to markup -languages: -

    -
    • the XML standard: - http://www.w3.org/TR/REC-xml - -
    • - - -
    • Namespaces in XML: - http://www.w3.org/TR/REC-xml-names/ - -
    • - - -
    • XML Base: - http://www.w3.org/TR/xmlbase/ - -
    • - - -
    • RFC 2396 - - : - Uniform Resource Identifiers - http://www.ietf.org/rfc/rfc2396.txt - -
    • - - -
    • XML Path Language (XPath) 1.0: - http://www.w3.org/TR/xpath - -
    • - - -
    • HTML4 parser: - http://www.w3.org/TR/html401/ - -
    • - - -
    • XML Pointer Language (XPointer) Version 1.0: - http://www.w3.org/TR/xptr - -
    • - - -
    • XML Inclusions (XInclude) Version 1.0: - http://www.w3.org/TR/xinclude/ - -
    • - - -
    • ISO-8859-x encodings, as well as - rfc2044 - - [UTF-8] - and - rfc2781 - - - [UTF-16] Unicode encodings, and more if using iconv support -
    • - - -
    • part of SGML Open Technical Resolution TR9401:1997 -
    • - - -
    • XML Catalogs Working Draft 06 August 2001: - http://www.oasis-open.org/committees/entity/spec-2001-08-06.html - -
    • - - -
    • Canonical XML Version 1.0: - http://www.w3.org/TR/xml-c14n - - - and the Exclusive XML Canonicalization CR draft - http://www.w3.org/TR/xml-exc-c14n - -
    • - - -
    • Relax NG, ISO/IEC 19757-2:2003, - http://www.oasis-open.org/committees/relax-ng/spec-20011203.html - -
    • - - -
    • W3C XML Schemas Part 2: Datatypes - REC 02 May - 2001 - -
    • - - -
    • W3C - xml:id - - Working Draft 7 - April 2004 -
    • - - +languages:

      +

      In most cases libxml2 tries to implement the specifications in a relatively strictly compliant way. As of release 2.4.16, libxml2 passed all -1800+ tests from the - OASIS XML Tests -Suite - -. -

      +1800+ tests from the OASIS XML Tests +Suite.

      To some extent libxml2 provides support for the following additional -specifications but doesn't claim to implement them completely: -

      -
      • Document Object Model (DOM) - http://www.w3.org/TR/DOM-Level-2-Core/ - - +specifications but doesn't claim to implement them completely:

        +
        • Document Object Model (DOM) http://www.w3.org/TR/DOM-Level-2-Core/ the document model, but it doesn't implement the API itself, gdome2 does - this on top of libxml2 -
        • - - -
        • RFC 959 - - : - libxml2 implements a basic FTP client code -
        • - - -
        • RFC 1945 - - : - HTTP/1.0, again a basic HTTP client code -
        • - - -
        • SAX: a SAX2 like interface and a minimal SAX1 implementation compatible - with early expat versions -
        • - - + this on top of libxml2 +
        • RFC 959 : + libxml2 implements a basic FTP client code
        • +
        • RFC 1945 : + HTTP/1.0, again a basic HTTP client code
        • +
        • SAX: a SAX2 like interface and a minimal SAX1 implementation compatible + with early expat versions
        -

        A partial implementation of - XML Schemas Part -1: Structure - - is being worked on but it would be far too early to make any -conformance statement about it at the moment. -

        -

        Separate documents: -

        -
        • the libxslt page - - providing an +

          A partial implementation of XML Schemas Part +1: Structure is being worked on but it would be far too early to make any +conformance statement about it at the moment.

          +

          Separate documents:

          + -

          Logo designed by - Marc Liyanage - -. -

          +

          Logo designed by Marc Liyanage.

          - Daniel Veillard - + Daniel Veillard

          diff --git a/test/schemas/date_0.xml b/test/schemas/date_0.xml index fbef1e5e..6c677edb 100644 --- a/test/schemas/date_0.xml +++ b/test/schemas/date_0.xml @@ -12,6 +12,7 @@ 2000-05-18Z 2000-05-18T00:00:00 2002-05-19T21:30:00.99 + 1969-12-31T23:00:01-01:00 --01-01 --07-04 --12-25 diff --git a/xmlschemastypes.c b/xmlschemastypes.c index 9ed7fb07..6cd13ae9 100644 --- a/xmlschemastypes.c +++ b/xmlschemastypes.c @@ -2607,6 +2607,26 @@ xmlSchemaCompareDurations(xmlSchemaValPtr x, xmlSchemaValPtr y) #define FQUOTIENT_RANGE(a,low,high) (FQUOTIENT((a-low),(high-low))) #define MODULO_RANGE(a,low,high) ((MODULO((a-low),(high-low)))+low) +/** + * xmlSchemaDupVal: + * @v: the #xmlSchemaValPtr value to duplicate + * + * Makes a copy of @v. The calling program is responsible for freeing + * the returned value. + * + * returns a pointer to a duplicated #xmlSchemaValPtr or NULL if error. + */ +static xmlSchemaValPtr +xmlSchemaDupVal (xmlSchemaValPtr v) +{ + xmlSchemaValPtr ret = xmlSchemaNewValue(v->type); + if (ret == NULL) + return NULL; + + memcpy(ret, v, sizeof(xmlSchemaVal)); + return ret; +} + /** * _xmlSchemaDateAdd: * @dt: an #xmlSchemaValPtr @@ -2614,14 +2634,15 @@ xmlSchemaCompareDurations(xmlSchemaValPtr x, xmlSchemaValPtr y) * * Compute a new date/time from @dt and @dur. This function assumes @dt * is either #XML_SCHEMAS_DATETIME, #XML_SCHEMAS_DATE, #XML_SCHEMAS_GYEARMONTH, - * or #XML_SCHEMAS_GYEAR. + * or #XML_SCHEMAS_GYEAR. The returned #xmlSchemaVal is the same type as + * @dt. The calling program is responsible for freeing the returned value. * - * Returns date/time pointer or NULL. + * Returns a pointer to a new #xmlSchemaVal or NULL if error. */ static xmlSchemaValPtr _xmlSchemaDateAdd (xmlSchemaValPtr dt, xmlSchemaValPtr dur) { - xmlSchemaValPtr ret; + xmlSchemaValPtr ret, tmp; long carry, tempdays, temp; xmlSchemaValDatePtr r, d; xmlSchemaValDurationPtr u; @@ -2633,8 +2654,15 @@ _xmlSchemaDateAdd (xmlSchemaValPtr dt, xmlSchemaValPtr dur) if (ret == NULL) return NULL; + /* make a copy so we don't alter the original value */ + tmp = xmlSchemaDupVal(dt); + if (tmp == NULL) { + xmlSchemaFreeValue(ret); + return NULL; + } + r = &(ret->value.date); - d = &(dt->value.date); + d = &(tmp->value.date); u = &(dur->value.dur); /* normalization */ @@ -2740,32 +2768,20 @@ _xmlSchemaDateAdd (xmlSchemaValPtr dt, xmlSchemaValPtr dur) } } - return ret; -} + xmlSchemaFreeValue(tmp); -/** - * xmlSchemaDupVal: - * @v: value to duplicate - * - * returns a duplicated value. - */ -static xmlSchemaValPtr -xmlSchemaDupVal (xmlSchemaValPtr v) -{ - xmlSchemaValPtr ret = xmlSchemaNewValue(v->type); - if (ret == NULL) - return ret; - - memcpy(ret, v, sizeof(xmlSchemaVal)); return ret; } /** * xmlSchemaDateNormalize: - * @dt: an #xmlSchemaValPtr + * @dt: an #xmlSchemaValPtr of a date/time type value. + * @offset: number of seconds to adjust @dt by. * - * Normalize @dt to GMT time. + * Normalize @dt to GMT time. The @offset parameter is subtracted from + * the return value is a time-zone offset is present on @dt. * + * Returns a normalized copy of @dt or NULL if error. */ static xmlSchemaValPtr xmlSchemaDateNormalize (xmlSchemaValPtr dt, double offset)