1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-30 22:43:14 +03:00

extended the XmlTextReader API a bit, addding accessors for the current

* xmlreader.c include/libxml/xmlreader.h doc/libxml2-api.xml:
  extended the XmlTextReader API a bit, addding accessors for
  the current doc and node, and an entity substitution mode for
  the parser.
* python/libxml.py python/libxml2class.txt: related updates
* python/tests/Makefile.am python/tests/reader.py
  python/tests/reader2.py python/tests/reader3.py: updated a bit
  the old tests and added a new one to test the entities handling
Daniel
This commit is contained in:
Daniel Veillard
2002-12-28 22:56:33 +00:00
parent aba976d825
commit e18fc185fa
10 changed files with 194 additions and 4 deletions

View File

@ -1864,6 +1864,13 @@ xmlTextReaderSetParserProp(xmlTextReaderPtr reader, int prop, int value) {
ctxt->validate = 0;
}
return(0);
case XML_PARSER_SUBST_ENTITIES:
if (value != 0) {
ctxt->replaceEntities = 1;
} else {
ctxt->replaceEntities = 0;
}
return(0);
}
return(-1);
}
@ -1897,10 +1904,50 @@ xmlTextReaderGetParserProp(xmlTextReaderPtr reader, int prop) {
return(0);
case XML_PARSER_VALIDATE:
return(ctxt->validate);
case XML_PARSER_SUBST_ENTITIES:
return(ctxt->replaceEntities);
}
return(-1);
}
/**
* xmlTextReaderCurrentNode:
* @reader: the xmlTextReaderPtr used
*
* Hacking interface allowing to get the xmlNodePtr correponding to the
* current node being accessed by the xmlTextReader. This is dangerous
* because the underlying node may be destroyed on the next Reads.
*
* Returns the xmlNodePtr or NULL in case of error.
*/
xmlNodePtr
xmlTextReaderCurrentNode(xmlTextReaderPtr reader) {
if (reader == NULL)
return(NULL);
if (reader->curnode != NULL)
return(reader->curnode);
return(reader->node);
}
/**
* xmlTextReaderCurrentDoc:
* @reader: the xmlTextReaderPtr used
*
* Hacking interface allowing to get the xmlDocPtr correponding to the
* current document being accessed by the xmlTextReader. This is dangerous
* because the associated node may be destroyed on the next Reads.
*
* Returns the xmlDocPtr or NULL in case of error.
*/
xmlDocPtr
xmlTextReaderCurrentDoc(xmlTextReaderPtr reader) {
if ((reader == NULL) || (reader->ctxt == NULL))
return(NULL);
return(reader->ctxt->myDoc);
}
/************************************************************************
* *
* Utilities *