diff options
author | Mike Hommey <mh@glandium.org> | 2004-10-28 09:07:41 +0000 |
---|---|---|
committer | Mike Hommey <mh@glandium.org> | 2004-10-28 09:07:41 +0000 |
commit | 9705f1a5e858108d21a0128556f42b25d16833cd (patch) | |
tree | f819e7482d433f8bf5da005695c79189dd5ce527 /xmlreader.c | |
parent | 0732be88d054db33fa0ca479eab9988c8e6be42e (diff) | |
download | libxml2-9705f1a5e858108d21a0128556f42b25d16833cd.tar.gz |
Load /tmp/tmp.SgII7T/libxml2-2.6.15 intoupstream/2.6.15
packages/libxml2/branches/upstream/current.
Diffstat (limited to 'xmlreader.c')
-rw-r--r-- | xmlreader.c | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/xmlreader.c b/xmlreader.c index 58fbe2e..e3243b9 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 * |