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:
47
xmlreader.c
47
xmlreader.c
@ -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 *
|
||||
|
Reference in New Issue
Block a user