version 1.138, 2000/11/03 13:45:27
|
version 1.139, 2000/11/05 17:22:12
|
Line 2932 xmlNodeSetBase(xmlNodePtr cur, xmlChar*
|
Line 2932 xmlNodeSetBase(xmlNodePtr cur, xmlChar*
|
} |
} |
|
|
/** |
/** |
|
* xmlDocumentGetBase: |
|
* @doc: the document |
|
* |
|
* Searches for the Document BASE URL. The code should work on both XML |
|
* and HTML document. |
|
* It returns the base as defined in RFC 2396 section |
|
* 5.1.3. Base URI from the Retrieval URI |
|
* However it does not return the computed base (5.1.1 and 5.1.2), use |
|
* xmlNodeGetBase() for this |
|
* |
|
* Returns a pointer to the base URL, or NULL if not found |
|
* It's up to the caller to free the memory. |
|
*/ |
|
xmlChar * |
|
xmlDocumentGetBase(xmlDocPtr doc) { |
|
if (doc == NULL) |
|
return(NULL); |
|
if (doc->type == XML_HTML_DOCUMENT_NODE) { |
|
if (doc->URL != NULL) |
|
return(xmlStrdup(doc->URL)); |
|
return(NULL); |
|
} |
|
if (doc->URL != NULL) |
|
return(xmlStrdup(doc->URL)); |
|
return(NULL); |
|
} |
|
|
|
/** |
* xmlNodeGetBase: |
* xmlNodeGetBase: |
* @doc: the document the node pertains to |
* @doc: the document the node pertains to |
* @cur: the node being checked |
* @cur: the node being checked |
* |
* |
* Searches for the BASE URL. The code should work on both XML |
* Searches for the BASE URL. The code should work on both XML |
* and HTML document even if base mechanisms are completely different. |
* and HTML document even if base mechanisms are completely different. |
|
* It returns the base as defined in RFC 2396 sections |
|
* 5.1.1. Base URI within Document Content |
|
* and |
|
* 5.1.2. Base URI from the Encapsulating Entity |
|
* However it does not return the document base (5.1.3), use |
|
* xmlDocumentGetBase() for this |
* |
* |
* Returns a pointer to the base URL, or NULL if not found |
* Returns a pointer to the base URL, or NULL if not found |
* It's up to the caller to free the memory. |
* It's up to the caller to free the memory. |
Line 2952 xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr
|
Line 2986 xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr
|
if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) { |
if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) { |
cur = doc->children; |
cur = doc->children; |
while ((cur != NULL) && (cur->name != NULL)) { |
while ((cur != NULL) && (cur->name != NULL)) { |
if (cur->type == XML_ENTITY_DECL) { |
|
/* TODO: we are crossing entity boundaries */ |
|
} |
|
if (cur->type != XML_ELEMENT_NODE) { |
if (cur->type != XML_ELEMENT_NODE) { |
cur = cur->next; |
cur = cur->next; |
continue; |
continue; |
Line 2972 xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr
|
Line 3003 xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr
|
} |
} |
cur = cur->next; |
cur = cur->next; |
} |
} |
if ((doc != NULL) && (doc->URL != NULL)) |
|
return(xmlStrdup(doc->URL)); |
|
return(NULL); |
return(NULL); |
} |
} |
while (cur != NULL) { |
while (cur != NULL) { |
|
if (cur->type == XML_ENTITY_DECL) { |
|
xmlEntityPtr ent = (xmlEntityPtr) cur; |
|
return(xmlStrdup(ent->URI)); |
|
} |
base = xmlGetProp(cur, BAD_CAST "xml:base"); |
base = xmlGetProp(cur, BAD_CAST "xml:base"); |
if (base != NULL) |
if (base != NULL) |
return(base); |
return(base); |
cur = cur->parent; |
cur = cur->parent; |
} |
} |
if ((doc != NULL) && (doc->URL != NULL)) |
|
return(xmlStrdup(doc->URL)); |
|
return(NULL); |
return(NULL); |
} |
} |
|
|