summaryrefslogtreecommitdiff
path: root/xmlreader.c
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2004-07-06 12:57:17 +0000
committerMike Hommey <mh@glandium.org>2004-07-06 12:57:17 +0000
commitc14c53a3645d81281058d4bb4cff24fa8d6faf33 (patch)
tree29bccc2e7499af078a3d1cdcfb517a1dee891be5 /xmlreader.c
parentd4e028c96af89ade493b440d4f2de6b684c03a06 (diff)
downloadlibxml2-c14c53a3645d81281058d4bb4cff24fa8d6faf33.tar.gz
Load /tmp/tmp.DIvcnD/libxml2-2.6.11 intoupstream/2.6.11
packages/libxml2/branches/upstream/current.
Diffstat (limited to 'xmlreader.c')
-rw-r--r--xmlreader.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/xmlreader.c b/xmlreader.c
index f3225aa..f1ea238 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -1224,6 +1224,7 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
reader->state = XML_TEXTREADER_ELEMENT;
}
reader->depth = 0;
+ reader->ctxt->parseMode = XML_PARSE_READER;
goto node_found;
}
oldstate = reader->state;
@@ -1920,6 +1921,7 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
ret->base = 0;
ret->cur = 0;
}
+
if (ret->ctxt == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlNewTextReader : malloc failed\n");
@@ -1927,6 +1929,7 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
xmlFree(ret);
return(NULL);
}
+ ret->ctxt->parseMode = XML_PARSE_READER;
ret->ctxt->_private = ret;
ret->ctxt->linenumbers = 1;
ret->ctxt->dictNames = 1;
@@ -3291,6 +3294,13 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) {
(attr->children->next == NULL))
return(attr->children->content);
else {
+ if (reader->buffer == NULL)
+ reader->buffer = xmlBufferCreateSize(100);
+ if (reader->buffer == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlTextReaderSetup : malloc failed\n");
+ return (NULL);
+ }
reader->buffer->use = 0;
xmlNodeBufGetContent(reader->buffer, node);
return(reader->buffer->content);
@@ -3544,9 +3554,9 @@ xmlTextReaderCurrentNode(xmlTextReaderPtr reader) {
* xmlTextReaderPreserve:
* @reader: the xmlTextReaderPtr used
*
- *
- * current node being accessed by the xmlTextReader. This is dangerous
- * because the underlying node may be destroyed on the next Reads.
+ * This tells the XML Reader to preserve the current node.
+ * The caller must also use xmlTextReaderCurrentDoc() to
+ * keep an handle on the resulting document once parsing has finished
*
* Returns the xmlNodePtr or NULL in case of error.
*/
@@ -3564,7 +3574,7 @@ xmlTextReaderPreserve(xmlTextReaderPtr reader) {
if (cur == NULL)
return(NULL);
- if (cur->type != XML_DOCUMENT_NODE) {
+ if ((cur->type != XML_DOCUMENT_NODE) && (cur->type != XML_DTD_NODE)) {
cur->extra |= NODE_IS_PRESERVED;
cur->extra |= NODE_IS_SPRESERVED;
}
@@ -4231,6 +4241,7 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
* use the parser dictionnary to allocate all elements and attributes names
*/
reader->ctxt->docdict = 1;
+ reader->ctxt->parseMode = XML_PARSE_READER;
#ifdef LIBXML_XINCLUDE_ENABLED
if (reader->xincctxt != NULL) {