version 1.48, 2000/02/17 10:03:23
|
version 1.49, 2000/02/21 09:33:35
|
Line 158 internalSubset(void *ctx, const xmlChar
|
Line 158 internalSubset(void *ctx, const xmlChar
|
name, ExternalID, SystemID); |
name, ExternalID, SystemID); |
#endif |
#endif |
xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID); |
xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID); |
|
} |
|
|
|
/** |
|
* externalSubset: |
|
* @ctx: the user data (XML parser context) |
|
* |
|
* Callback on external subset declaration. |
|
*/ |
|
void |
|
externalSubset(void *ctx, const xmlChar *name, |
|
const xmlChar *ExternalID, const xmlChar *SystemID) |
|
{ |
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
|
#ifdef DEBUG_SAX |
|
fprintf(stderr, "SAX.externalSubset(%s, %s, %s)\n", |
|
name, ExternalID, SystemID); |
|
#endif |
if (((ExternalID != NULL) || (SystemID != NULL)) && |
if (((ExternalID != NULL) || (SystemID != NULL)) && |
(ctxt->validate && ctxt->wellFormed && ctxt->myDoc)) { |
(ctxt->validate && ctxt->wellFormed && ctxt->myDoc)) { |
/* |
/* |
* Try to fetch and parse the external subset. |
* Try to fetch and parse the external subset. |
*/ |
*/ |
xmlDtdPtr ret = NULL; |
xmlParserInputPtr oldinput; |
xmlParserCtxtPtr dtdCtxt; |
int oldinputNr; |
|
int oldinputMax; |
|
xmlParserInputPtr *oldinputTab; |
xmlParserInputPtr input = NULL; |
xmlParserInputPtr input = NULL; |
xmlCharEncoding enc; |
xmlCharEncoding enc; |
|
|
dtdCtxt = xmlNewParserCtxt(); |
|
if (dtdCtxt == NULL) return; |
|
|
|
/* |
/* |
* Ask the Entity resolver to load the damn thing |
* Ask the Entity resolver to load the damn thing |
*/ |
*/ |
if ((ctxt->directory != NULL) && (dtdCtxt->directory == NULL)) |
if ((ctxt->sax != NULL) && (ctxt->sax->resolveEntity != NULL)) |
dtdCtxt->directory = (char *) xmlStrdup(BAD_CAST ctxt->directory); |
input = ctxt->sax->resolveEntity(ctxt->userData, ExternalID, |
|
|
if ((dtdCtxt->sax != NULL) && (dtdCtxt->sax->resolveEntity != NULL)) |
|
input = dtdCtxt->sax->resolveEntity(dtdCtxt->userData, ExternalID, |
|
SystemID); |
SystemID); |
if (input == NULL) { |
if (input == NULL) { |
xmlFreeParserCtxt(dtdCtxt); |
|
return; |
return; |
} |
} |
|
|
xmlPushInput(dtdCtxt, input); |
/* |
|
* make sure we won't destroy the main document context |
|
*/ |
|
oldinput = ctxt->input; |
|
oldinputNr = ctxt->inputNr; |
|
oldinputMax = ctxt->inputMax; |
|
oldinputTab = ctxt->inputTab; |
|
|
|
ctxt->inputTab = (xmlParserInputPtr *) |
|
xmlMalloc(5 * sizeof(xmlParserInputPtr)); |
|
if (ctxt->inputTab == NULL) { |
|
ctxt->errNo = XML_ERR_NO_MEMORY; |
|
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) |
|
ctxt->sax->error(ctxt->userData, |
|
"externalSubset: out of memory\n"); |
|
ctxt->errNo = XML_ERR_NO_MEMORY; |
|
ctxt->input = oldinput; |
|
ctxt->inputNr = oldinputNr; |
|
ctxt->inputMax = oldinputMax; |
|
ctxt->inputTab = oldinputTab; |
|
return; |
|
} |
|
ctxt->inputNr = 0; |
|
ctxt->inputMax = 5; |
|
ctxt->input = NULL; |
|
xmlPushInput(ctxt, input); |
|
|
/* |
/* |
* On the fly encoding conversion if needed |
* On the fly encoding conversion if needed |
*/ |
*/ |
enc = xmlDetectCharEncoding(dtdCtxt->input->cur, 4); |
enc = xmlDetectCharEncoding(ctxt->input->cur, 4); |
xmlSwitchEncoding(dtdCtxt, enc); |
xmlSwitchEncoding(ctxt, enc); |
|
|
if (input->filename == NULL) |
if (input->filename == NULL) |
input->filename = (char *) xmlStrdup(SystemID); |
input->filename = (char *) xmlStrdup(SystemID); |
input->line = 1; |
input->line = 1; |
input->col = 1; |
input->col = 1; |
input->base = dtdCtxt->input->cur; |
input->base = ctxt->input->cur; |
input->cur = dtdCtxt->input->cur; |
input->cur = ctxt->input->cur; |
input->free = NULL; |
input->free = NULL; |
|
|
/* |
/* |
* let's parse that entity knowing it's an external subset. |
* let's parse that entity knowing it's an external subset. |
*/ |
*/ |
xmlParseExternalSubset(dtdCtxt, ExternalID, SystemID); |
xmlParseExternalSubset(ctxt, ExternalID, SystemID); |
|
|
if (dtdCtxt->myDoc != NULL) { |
/* |
if (dtdCtxt->wellFormed) { |
* Free up the external entities |
ret = dtdCtxt->myDoc->intSubset; |
*/ |
dtdCtxt->myDoc->intSubset = NULL; |
|
} else { |
while (ctxt->inputNr > 1) |
ret = NULL; |
xmlPopInput(ctxt); |
} |
xmlFreeInputStream(ctxt->input); |
xmlFreeDoc(dtdCtxt->myDoc); |
xmlFree(ctxt->inputTab); |
dtdCtxt->myDoc = NULL; |
|
} |
/* |
xmlFreeParserCtxt(dtdCtxt); |
* Restore the parsing context of the main entity |
|
*/ |
ctxt->myDoc->extSubset = ret; |
ctxt->input = oldinput; |
|
ctxt->inputNr = oldinputNr; |
|
ctxt->inputMax = oldinputMax; |
|
ctxt->inputTab = oldinputTab; |
} |
} |
} |
} |
|
|
Line 1171 xmlSAXHandler xmlDefaultSAXHandler = {
|
Line 1211 xmlSAXHandler xmlDefaultSAXHandler = {
|
xmlParserError, |
xmlParserError, |
getParameterEntity, |
getParameterEntity, |
cdataBlock, |
cdataBlock, |
|
externalSubset, |
}; |
}; |
|
|
/** |
/** |
Line 1182 void
|
Line 1223 void
|
xmlDefaultSAXHandlerInit(void) |
xmlDefaultSAXHandlerInit(void) |
{ |
{ |
xmlDefaultSAXHandler.internalSubset = internalSubset; |
xmlDefaultSAXHandler.internalSubset = internalSubset; |
|
xmlDefaultSAXHandler.externalSubset = externalSubset; |
xmlDefaultSAXHandler.isStandalone = isStandalone; |
xmlDefaultSAXHandler.isStandalone = isStandalone; |
xmlDefaultSAXHandler.hasInternalSubset = hasInternalSubset; |
xmlDefaultSAXHandler.hasInternalSubset = hasInternalSubset; |
xmlDefaultSAXHandler.hasExternalSubset = hasExternalSubset; |
xmlDefaultSAXHandler.hasExternalSubset = hasExternalSubset; |
Line 1242 xmlSAXHandler htmlDefaultSAXHandler = {
|
Line 1284 xmlSAXHandler htmlDefaultSAXHandler = {
|
xmlParserError, |
xmlParserError, |
getParameterEntity, |
getParameterEntity, |
NULL, |
NULL, |
|
NULL, |
}; |
}; |
|
|
/** |
/** |
Line 1253 void
|
Line 1296 void
|
htmlDefaultSAXHandlerInit(void) |
htmlDefaultSAXHandlerInit(void) |
{ |
{ |
htmlDefaultSAXHandler.internalSubset = NULL; |
htmlDefaultSAXHandler.internalSubset = NULL; |
|
htmlDefaultSAXHandler.externalSubset = NULL; |
htmlDefaultSAXHandler.isStandalone = NULL; |
htmlDefaultSAXHandler.isStandalone = NULL; |
htmlDefaultSAXHandler.hasInternalSubset = NULL; |
htmlDefaultSAXHandler.hasInternalSubset = NULL; |
htmlDefaultSAXHandler.hasExternalSubset = NULL; |
htmlDefaultSAXHandler.hasExternalSubset = NULL; |