version 1.32, 1999/10/08 09:35:42
|
version 1.33, 1999/10/11 11:54:58
|
Line 2962 xmlValidateDocument(xmlValidCtxtPtr ctxt
|
Line 2962 xmlValidateDocument(xmlValidCtxtPtr ctxt
|
return(ret); |
return(ret); |
} |
} |
|
|
|
|
|
/************************************************************************ |
|
* * |
|
* Routines for dynamic validation editing * |
|
* * |
|
************************************************************************/ |
|
|
|
/** |
|
* xmlValidateGetPreList: |
|
* @node: a node instance |
|
* |
|
* Compute the string containing the names of previous siblings of the node |
|
* |
|
* returns the string or NULL if empty. Caller must deallocate it |
|
*/ |
|
|
|
xmlChar * |
|
xmlValidateGetPreList(xmlNodePtr node) { |
|
xmlNodePtr cur; |
|
const xmlChar *tmp; |
|
xmlChar *ret, *res, *end; |
|
int len = 100; |
|
|
|
if (node == NULL) return(NULL); |
|
if (node->prev == NULL) return(NULL); |
|
ret = (xmlChar *) xmlMalloc(len * sizeof(xmlChar)); |
|
if (ret == NULL) { |
|
fprintf(stderr, "xmlValidateGetPreList: malloc() failed !\n"); |
|
return(NULL); |
|
} |
|
end = &ret[len - 1]; |
|
|
|
cur = node->prev; |
|
while (cur->prev != NULL) cur = cur->prev; |
|
|
|
while ((cur != NULL) && (cur != node)) { |
|
tmp = cur->name; |
|
while ((tmp != NULL) && (*tmp != 0)) { |
|
if (res == end) { |
|
int index = res - ret; |
|
len *= 2; |
|
ret = (xmlChar *) realloc(ret, len * sizeof(xmlChar)); |
|
if (ret == NULL) { |
|
fprintf(stderr, |
|
"xmlValidateGetPreList: realloc() failed !\n"); |
|
return(NULL); |
|
} |
|
res = ret + index; |
|
end = &ret[len - 1]; |
|
} |
|
*res++ = *tmp++; |
|
} |
|
*res++ = ' '; |
|
cur = cur->next; |
|
} |
|
*res = 0; |
|
return(ret); |
|
} |
|
|
|
|
|
/** |
|
* xmlValidateGetPostList: |
|
* @node: a node instance |
|
* |
|
* Compute the string containing the names of next siblings of the node |
|
* |
|
* returns the string or NULL if empty. Caller must deallocate it |
|
*/ |
|
|
|
xmlChar * |
|
xmlValidateGetPostList(xmlNodePtr node) { |
|
xmlNodePtr cur; |
|
const xmlChar *tmp; |
|
xmlChar *ret, *res, *end; |
|
int len = 100; |
|
|
|
if (node == NULL) return(NULL); |
|
if (node->next == NULL) return(NULL); |
|
ret = (xmlChar *) xmlMalloc(len * sizeof(xmlChar)); |
|
if (ret == NULL) { |
|
fprintf(stderr, "xmlValidateGetPreList: malloc() failed !\n"); |
|
return(NULL); |
|
} |
|
end = &ret[len - 1]; |
|
|
|
cur = node->next; |
|
|
|
while (cur != NULL) { |
|
tmp = cur->name; |
|
while ((tmp != NULL) && (*tmp != 0)) { |
|
if (res == end) { |
|
int index = res - ret; |
|
len *= 2; |
|
ret = (xmlChar *) realloc(ret, len * sizeof(xmlChar)); |
|
if (ret == NULL) { |
|
fprintf(stderr, |
|
"xmlValidateGetPreList: realloc() failed !\n"); |
|
return(NULL); |
|
} |
|
res = ret + index; |
|
end = &ret[len - 1]; |
|
} |
|
*res++ = *tmp++; |
|
} |
|
*res++ = ' '; |
|
cur = cur->next; |
|
} |
|
*res = 0; |
|
return(ret); |
|
} |
|
|