version 1.5, 2000/11/06 22:19:48
|
version 1.6, 2000/11/07 09:54:46
|
Line 285 xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ct
|
Line 285 xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ct
|
xmlDocPtr doc; |
xmlDocPtr doc; |
xmlURIPtr uri; |
xmlURIPtr uri; |
xmlChar *URL; |
xmlChar *URL; |
|
xmlChar *fragment = NULL; |
int i; |
int i; |
/* |
/* |
* Check the URL and remove any fragment identifier |
* Check the URL and remove any fragment identifier |
Line 296 xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ct
|
Line 297 xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ct
|
return; |
return; |
} |
} |
if (uri->fragment != NULL) { |
if (uri->fragment != NULL) { |
xmlFree(uri->fragment); |
fragment = (xmlChar *) uri->fragment; |
uri->fragment = NULL; /* TODO: kkep it for later processing */ |
uri->fragment = NULL; |
} |
} |
URL = xmlSaveUri(uri); |
URL = xmlSaveUri(uri); |
xmlFreeURI(uri); |
xmlFreeURI(uri); |
if (URL == NULL) { |
if (URL == NULL) { |
xmlGenericError(xmlGenericErrorContext, |
xmlGenericError(xmlGenericErrorContext, |
"XInclude: invalid value URI %s\n", url); |
"XInclude: invalid value URI %s\n", url); |
|
if (fragment != NULL) |
|
xmlFree(fragment); |
return; |
return; |
} |
} |
|
|
Line 311 xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ct
|
Line 314 xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ct
|
* Handling of references to the local document are done |
* Handling of references to the local document are done |
* directly through ctxt->doc. |
* directly through ctxt->doc. |
*/ |
*/ |
if (URL[0] == 0) { |
if ((URL[0] == 0) || (URL[0] == '#')) { |
xmlFree(URL); |
doc = NULL; |
return; |
goto loaded; |
} |
} |
|
|
/* |
/* |
Line 333 xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ct
|
Line 336 xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ct
|
xmlGenericError(xmlGenericErrorContext, |
xmlGenericError(xmlGenericErrorContext, |
"XInclude: could not load %s\n", URL); |
"XInclude: could not load %s\n", URL); |
xmlFree(URL); |
xmlFree(URL); |
|
if (fragment != NULL) |
|
xmlFree(fragment); |
return; |
return; |
} |
} |
xmlXIncludeAddDoc(ctxt, doc, URL); |
xmlXIncludeAddDoc(ctxt, doc, URL); |
|
|
loaded: |
loaded: |
/* |
if (fragment == NULL) { |
* Add the top children list as the replacement copy. |
/* |
*/ |
* Add the top children list as the replacement copy. |
ctxt->repTab[nr] = xmlCopyNodeList(doc->children); |
* ISSUE: seems we should scrap DTD info from the copied list. |
|
*/ |
|
if (doc == NULL) |
|
ctxt->repTab[nr] = xmlCopyNodeList(ctxt->doc->children); |
|
else |
|
ctxt->repTab[nr] = xmlCopyNodeList(doc->children); |
|
} else { |
|
/* |
|
* Computes the XPointer expression and make a copy used |
|
* as the replacement copy. |
|
*/ |
|
xmlXPathObjectPtr xptr; |
|
xmlXPathContextPtr xptrctxt; |
|
|
|
if (doc == NULL) { |
|
xptrctxt = xmlXPtrNewContext(ctxt->doc, ctxt->incTab[nr], NULL); |
|
} else { |
|
xptrctxt = xmlXPtrNewContext(doc, NULL, NULL); |
|
} |
|
if (xptrctxt == NULL) { |
|
xmlGenericError(xmlGenericErrorContext, |
|
"XInclude: could create XPointer context\n"); |
|
xmlFree(URL); |
|
xmlFree(fragment); |
|
return; |
|
} |
|
xptr = xmlXPtrEval(fragment, xptrctxt); |
|
if (xptr == NULL) { |
|
xmlGenericError(xmlGenericErrorContext, |
|
"XInclude: XPointer evaluation failed: #%s\n", |
|
fragment); |
|
xmlFree(URL); |
|
xmlFree(fragment); |
|
return; |
|
} |
|
ctxt->repTab[nr] = xmlXPtrBuildNodeList(xptr); |
|
xmlXPathFreeObject(xptr); |
|
xmlXPathFreeContext(xptrctxt); |
|
xmlFree(fragment); |
|
} |
xmlFree(URL); |
xmlFree(URL); |
} |
} |
|
|