Commit e2811270 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

applied patch from Graham Bennett adding 4 convenience functions to the

* include/libxml/xmlreader.h xmlreader.c: applied patch from
  Graham Bennett adding 4 convenience functions to the reader API.
Daniel
parent 9638d4c2
Tue Oct 19 11:06:39 CEST 2004 Daniel Veillard <daniel@veillard.com>
* 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 <wbrack@mmm.com.hk>
 
* debugXML.c: excluded a few nodes (with no content) from the
......
......@@ -217,7 +217,8 @@ pnode=pxmlDoc-&gt;children-&gt;children;</pre>
<p>Website: <a
href="http://pmade.org/pjones/software/xmlwrapp/">http://pmade.org/pjones/software/xmlwrapp/</a></p>
</li>
--></ul></li>
-->
</ul></li>
<li>How to validate a document a posteriori ?
<p>It is possible to validate documents which had not been validated at
initial parsing time or documents which have been built from scratch
......
This diff is collapsed.
......@@ -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
......
......@@ -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 *
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment