diff --git a/ChangeLog b/ChangeLog index 0ff8e72f..6bd9b096 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Oct 19 11:06:39 CEST 2004 Daniel Veillard + + * include/libxml/xmlreader.h xmlreader.c: applied patch from + Graham Bennett adding 4 convenience functions to the reader API. + Fri Oct 15 11:22:48 PDT 2004 William Brack * debugXML.c: excluded a few nodes (with no content) from the diff --git a/doc/FAQ.html b/doc/FAQ.html index fa231404..62a392b5 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 7d198ae9..2d02b411 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/include/libxml/xmlreader.h b/include/libxml/xmlreader.h index e8104681..3d79006e 100644 --- a/include/libxml/xmlreader.h +++ b/include/libxml/xmlreader.h @@ -150,6 +150,8 @@ XMLPUBFUN int XMLCALL xmlTextReaderQuoteChar (xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderReadState (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader); XMLPUBFUN const xmlChar * XMLCALL xmlTextReaderConstBaseUri (xmlTextReaderPtr reader); @@ -226,6 +228,8 @@ XMLPUBFUN int XMLCALL xmlTextReaderMoveToElement (xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderNormalization (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstEncoding (xmlTextReaderPtr reader); /* * Extensions @@ -263,6 +267,10 @@ XMLPUBFUN int XMLCALL xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, xmlRelaxNGPtr schema); #endif +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderStandalone (xmlTextReaderPtr reader); /* * New more complete APIs for simpler creation and reuse of readers diff --git a/xmlreader.c b/xmlreader.c index 58fbe2e7..e3243b9d 100644 --- a/xmlreader.c +++ b/xmlreader.c @@ -2629,6 +2629,34 @@ xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader) { return(1); } +/** + * xmlTextReaderConstEncoding: + * @reader: the xmlTextReaderPtr used + * + * Determine the encoding of the document being read. + * + * Returns a string containing the encoding of the document or NULL in + * case of error. The string is deallocated with the reader. + */ +const xmlChar * +xmlTextReaderConstEncoding(xmlTextReaderPtr reader) { + xmlDocPtr doc = NULL; + if (reader == NULL) + return(NULL); + if (reader->doc != NULL) + doc = reader->doc; + else if (reader->ctxt != NULL) + doc = reader->ctxt->myDoc; + if (doc == NULL) + return(NULL); + + if (doc->encoding == NULL) + return(NULL); + else + return(CONSTSTR(doc->encoding)); +} + + /************************************************************************ * * * Acces API to the current node * @@ -3799,6 +3827,87 @@ xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, const char *rng) { } #endif +/** + * xmlTextReaderIsNamespaceDecl: + * @reader: the xmlTextReaderPtr used + * + * Determine whether the current node is a namespace declaration + * rather than a regular attribute. + * + * Returns 1 if the current node is a namespace declaration, 0 if it + * is a regular attribute or other type of node, or -1 in case of + * error. + */ +int +xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader) { + xmlNodePtr node; + if (reader == NULL) + return(-1); + if (reader->node == NULL) + return(-1); + if (reader->curnode != NULL) + node = reader->curnode; + else + node = reader->node; + + if (XML_NAMESPACE_DECL == node->type) + return(1); + else + return(0); +} + +/** + * xmlTextReaderConstXmlVersion: + * @reader: the xmlTextReaderPtr used + * + * Determine the XML version of the document being read. + * + * Returns a string containing the XML version of the document or NULL + * in case of error. The string is deallocated with the reader. + */ +const xmlChar * +xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader) { + xmlDocPtr doc = NULL; + if (reader == NULL) + return(NULL); + if (reader->doc != NULL) + doc = reader->doc; + else if (reader->ctxt != NULL) + doc = reader->ctxt->myDoc; + if (doc == NULL) + return(NULL); + + if (doc->version == NULL) + return(NULL); + else + return(CONSTSTR(doc->version)); +} + +/** + * xmlTextReaderStandalone: + * @reader: the xmlTextReaderPtr used + * + * Determine the standalone status of the document being read. + * + * Returns 1 if the document was declared to be standalone, 0 if it + * was declared to be not standalone, or -1 if the document did not + * specify its standalone status or in case of error. + */ +int +xmlTextReaderStandalone(xmlTextReaderPtr reader) { + xmlDocPtr doc = NULL; + if (reader == NULL) + return(-1); + if (reader->doc != NULL) + doc = reader->doc; + else if (reader->ctxt != NULL) + doc = reader->ctxt->myDoc; + if (doc == NULL) + return(-1); + + return(doc->standalone); +} + /************************************************************************ * * * Error Handling Extensions *