From 9705f1a5e858108d21a0128556f42b25d16833cd Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 28 Oct 2004 09:07:41 +0000 Subject: Load /tmp/tmp.SgII7T/libxml2-2.6.15 into packages/libxml2/branches/upstream/current. --- xmlreader.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) (limited to 'xmlreader.c') 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 * -- cgit v1.2.3