mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
- parser.[ch]: added xmlIOParseDTD()
- xpointer.c: added support for the 2 extra parameters of string-range, fixed a stoopid error when '0' was present in XPointer expressions - test/XPath/xptr/strrange2 result/XPath/xptr/strrange2: added testsuite for the above Daniel
This commit is contained in:
84
parser.c
84
parser.c
@ -8360,6 +8360,90 @@ xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* xmlIOParseDTD:
|
||||
* @sax: the SAX handler block or NULL
|
||||
* @input: an Input Buffer
|
||||
* @enc: the charset encoding if known
|
||||
*
|
||||
* Load and parse a DTD
|
||||
*
|
||||
* Returns the resulting xmlDtdPtr or NULL in case of error.
|
||||
*/
|
||||
|
||||
xmlDtdPtr
|
||||
xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
|
||||
xmlCharEncoding enc) {
|
||||
xmlDtdPtr ret = NULL;
|
||||
xmlParserCtxtPtr ctxt;
|
||||
xmlParserInputPtr pinput = NULL;
|
||||
|
||||
if (input == NULL)
|
||||
return(NULL);
|
||||
|
||||
ctxt = xmlNewParserCtxt();
|
||||
if (ctxt == NULL) {
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set-up the SAX context
|
||||
*/
|
||||
if (sax != NULL) {
|
||||
if (ctxt->sax != NULL)
|
||||
xmlFree(ctxt->sax);
|
||||
ctxt->sax = sax;
|
||||
ctxt->userData = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* generate a parser input from the I/O handler
|
||||
*/
|
||||
|
||||
pinput = xmlNewIOInputStream(ctxt, input, enc);
|
||||
if (pinput == NULL) {
|
||||
if (sax != NULL) ctxt->sax = NULL;
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* plug some encoding conversion routines here.
|
||||
*/
|
||||
xmlPushInput(ctxt, pinput);
|
||||
|
||||
pinput->filename = NULL;
|
||||
pinput->line = 1;
|
||||
pinput->col = 1;
|
||||
pinput->base = ctxt->input->cur;
|
||||
pinput->cur = ctxt->input->cur;
|
||||
pinput->free = NULL;
|
||||
|
||||
/*
|
||||
* let's parse that entity knowing it's an external subset.
|
||||
*/
|
||||
ctxt->inSubset = 2;
|
||||
ctxt->myDoc = xmlNewDoc(BAD_CAST "1.0");
|
||||
ctxt->myDoc->extSubset = xmlNewDtd(ctxt->myDoc, BAD_CAST "none",
|
||||
BAD_CAST "none", BAD_CAST "none");
|
||||
xmlParseExternalSubset(ctxt, BAD_CAST "none", BAD_CAST "none");
|
||||
|
||||
if (ctxt->myDoc != NULL) {
|
||||
if (ctxt->wellFormed) {
|
||||
ret = ctxt->myDoc->extSubset;
|
||||
ctxt->myDoc->extSubset = NULL;
|
||||
} else {
|
||||
ret = NULL;
|
||||
}
|
||||
xmlFreeDoc(ctxt->myDoc);
|
||||
ctxt->myDoc = NULL;
|
||||
}
|
||||
if (sax != NULL) ctxt->sax = NULL;
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlSAXParseDTD:
|
||||
* @sax: the SAX handler block
|
||||
|
Reference in New Issue
Block a user