version 1.1.1.1, 2012/02/21 23:37:57
|
version 1.1.1.3, 2014/06/15 19:53:29
|
Line 85 xmlCtxtDumpCleanCtxt(xmlDebugCtxtPtr ctxt ATTRIBUTE_UN
|
Line 85 xmlCtxtDumpCleanCtxt(xmlDebugCtxtPtr ctxt ATTRIBUTE_UN
|
* |
* |
* Check that a given namespace is in scope on a node. |
* Check that a given namespace is in scope on a node. |
* |
* |
* Returns 1 if in scope, -1 in case of argument error, | * Returns 1 if in scope, -1 in case of argument error, |
* -2 if the namespace is not in scope, and -3 if not on |
* -2 if the namespace is not in scope, and -3 if not on |
* an ancestor node. |
* an ancestor node. |
*/ |
*/ |
Line 311 xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodeP
|
Line 311 xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodeP
|
(node != (xmlNodePtr) node->parent->properties)) |
(node != (xmlNodePtr) node->parent->properties)) |
xmlDebugErr(ctxt, XML_CHECK_NO_PREV, |
xmlDebugErr(ctxt, XML_CHECK_NO_PREV, |
"Attr has no prev and not first of attr list\n"); |
"Attr has no prev and not first of attr list\n"); |
| |
} else if ((node->parent != NULL) && (node->parent->children != node)) |
} else if ((node->parent != NULL) && (node->parent->children != node)) |
xmlDebugErr(ctxt, XML_CHECK_NO_PREV, |
xmlDebugErr(ctxt, XML_CHECK_NO_PREV, |
"Node has no prev and not first of parent list\n"); |
"Node has no prev and not first of parent list\n"); |
Line 354 xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodeP
|
Line 354 xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodeP
|
(node->type != XML_ELEMENT_DECL) && |
(node->type != XML_ELEMENT_DECL) && |
(node->type != XML_ATTRIBUTE_DECL) && |
(node->type != XML_ATTRIBUTE_DECL) && |
(node->type != XML_DTD_NODE) && |
(node->type != XML_DTD_NODE) && |
(node->type != XML_ELEMENT_DECL) && |
|
(node->type != XML_HTML_DOCUMENT_NODE) && |
(node->type != XML_HTML_DOCUMENT_NODE) && |
(node->type != XML_DOCUMENT_NODE)) { |
(node->type != XML_DOCUMENT_NODE)) { |
if (node->content != NULL) |
if (node->content != NULL) |
Line 1068 xmlCtxtDumpNode(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
|
Line 1067 xmlCtxtDumpNode(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
|
return; |
return; |
} |
} |
xmlCtxtDumpOneNode(ctxt, node); |
xmlCtxtDumpOneNode(ctxt, node); |
if ((node->type != XML_NAMESPACE_DECL) && | if ((node->type != XML_NAMESPACE_DECL) && |
(node->children != NULL) && (node->type != XML_ENTITY_REF_NODE)) { |
(node->children != NULL) && (node->type != XML_ENTITY_REF_NODE)) { |
ctxt->depth++; |
ctxt->depth++; |
xmlCtxtDumpNodeList(ctxt, node->children); |
xmlCtxtDumpNodeList(ctxt, node->children); |
Line 1603 int
|
Line 1602 int
|
xmlLsCountNode(xmlNodePtr node) { |
xmlLsCountNode(xmlNodePtr node) { |
int ret = 0; |
int ret = 0; |
xmlNodePtr list = NULL; |
xmlNodePtr list = NULL; |
| |
if (node == NULL) |
if (node == NULL) |
return(0); |
return(0); |
|
|
Line 1644 xmlLsCountNode(xmlNodePtr node) {
|
Line 1643 xmlLsCountNode(xmlNodePtr node) {
|
ret = 1; |
ret = 1; |
break; |
break; |
} |
} |
for (;list != NULL;ret++) | for (;list != NULL;ret++) |
list = list->next; |
list = list->next; |
return(ret); |
return(ret); |
} |
} |
Line 1712 xmlLsOneNode(FILE *output, xmlNodePtr node) {
|
Line 1711 xmlLsOneNode(FILE *output, xmlNodePtr node) {
|
if (node->type != XML_NAMESPACE_DECL) { |
if (node->type != XML_NAMESPACE_DECL) { |
if (node->properties != NULL) |
if (node->properties != NULL) |
fprintf(output, "a"); |
fprintf(output, "a"); |
else | else |
fprintf(output, "-"); |
fprintf(output, "-"); |
if (node->nsDef != NULL) | if (node->nsDef != NULL) |
fprintf(output, "n"); |
fprintf(output, "n"); |
else | else |
fprintf(output, "-"); |
fprintf(output, "-"); |
} |
} |
|
|
Line 1724 xmlLsOneNode(FILE *output, xmlNodePtr node) {
|
Line 1723 xmlLsOneNode(FILE *output, xmlNodePtr node) {
|
|
|
switch (node->type) { |
switch (node->type) { |
case XML_ELEMENT_NODE: |
case XML_ELEMENT_NODE: |
if (node->name != NULL) | if (node->name != NULL) { |
| if ((node->ns != NULL) && (node->ns->prefix != NULL)) |
| fprintf(output, "%s:", node->ns->prefix); |
fprintf(output, "%s", (const char *) node->name); |
fprintf(output, "%s", (const char *) node->name); |
|
} |
break; |
break; |
case XML_ATTRIBUTE_NODE: |
case XML_ATTRIBUTE_NODE: |
if (node->name != NULL) |
if (node->name != NULL) |
Line 1783 xmlLsOneNode(FILE *output, xmlNodePtr node) {
|
Line 1785 xmlLsOneNode(FILE *output, xmlNodePtr node) {
|
* xmlBoolToText: |
* xmlBoolToText: |
* @boolval: a bool to turn into text |
* @boolval: a bool to turn into text |
* |
* |
* Convenient way to turn bool into text | * Convenient way to turn bool into text |
* |
* |
* Returns a pointer to either "True" or "False" |
* Returns a pointer to either "True" or "False" |
*/ |
*/ |
Line 1799 xmlBoolToText(int boolval)
|
Line 1801 xmlBoolToText(int boolval)
|
#ifdef LIBXML_XPATH_ENABLED |
#ifdef LIBXML_XPATH_ENABLED |
/**************************************************************** |
/**************************************************************** |
* * |
* * |
* The XML shell related functions * | * The XML shell related functions * |
* * |
* * |
****************************************************************/ |
****************************************************************/ |
|
|
Line 2050 xmlShellBase(xmlShellCtxtPtr ctxt,
|
Line 2052 xmlShellBase(xmlShellCtxtPtr ctxt,
|
if (node == NULL) { |
if (node == NULL) { |
fprintf(ctxt->output, "NULL\n"); |
fprintf(ctxt->output, "NULL\n"); |
return (0); |
return (0); |
} | } |
|
|
base = xmlNodeGetBase(node->doc, node); |
base = xmlNodeGetBase(node->doc, node); |
|
|
Line 2277 xmlShellDir(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
|
Line 2279 xmlShellDir(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
|
if (node == NULL) { |
if (node == NULL) { |
fprintf(ctxt->output, "NULL\n"); |
fprintf(ctxt->output, "NULL\n"); |
return (0); |
return (0); |
} | } |
if ((node->type == XML_DOCUMENT_NODE) || |
if ((node->type == XML_DOCUMENT_NODE) || |
(node->type == XML_HTML_DOCUMENT_NODE)) { |
(node->type == XML_HTML_DOCUMENT_NODE)) { |
xmlDebugDumpDocumentHead(ctxt->output, (xmlDocPtr) node); |
xmlDebugDumpDocumentHead(ctxt->output, (xmlDocPtr) node); |
Line 2412 xmlShellCat(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_
|
Line 2414 xmlShellCat(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_
|
if (node == NULL) { |
if (node == NULL) { |
fprintf(ctxt->output, "NULL\n"); |
fprintf(ctxt->output, "NULL\n"); |
return (0); |
return (0); |
} | } |
if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) { |
if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) { |
#ifdef LIBXML_HTML_ENABLED |
#ifdef LIBXML_HTML_ENABLED |
if (node->type == XML_HTML_DOCUMENT_NODE) |
if (node->type == XML_HTML_DOCUMENT_NODE) |
Line 2696 xmlShellDu(xmlShellCtxtPtr ctxt,
|
Line 2698 xmlShellDu(xmlShellCtxtPtr ctxt,
|
} else if (node->type == XML_ELEMENT_NODE) { |
} else if (node->type == XML_ELEMENT_NODE) { |
for (i = 0; i < indent; i++) |
for (i = 0; i < indent; i++) |
fprintf(ctxt->output, " "); |
fprintf(ctxt->output, " "); |
|
if ((node->ns) && (node->ns->prefix)) |
|
fprintf(ctxt->output, "%s:", node->ns->prefix); |
fprintf(ctxt->output, "%s\n", node->name); |
fprintf(ctxt->output, "%s\n", node->name); |
} else { |
} else { |
} |
} |
Line 2748 xmlShellDu(xmlShellCtxtPtr ctxt,
|
Line 2752 xmlShellDu(xmlShellCtxtPtr ctxt,
|
* xmlShellPwd: |
* xmlShellPwd: |
* @ctxt: the shell context |
* @ctxt: the shell context |
* @buffer: the output buffer |
* @buffer: the output buffer |
* @node: a node | * @node: a node |
* @node2: unused |
* @node2: unused |
* |
* |
* Implements the XML shell function "pwd" |
* Implements the XML shell function "pwd" |
Line 2793 xmlShellPwd(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED, cha
|
Line 2797 xmlShellPwd(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED, cha
|
* @input: the line reading function |
* @input: the line reading function |
* @output: the output FILE*, defaults to stdout if NULL |
* @output: the output FILE*, defaults to stdout if NULL |
* |
* |
* Implements the XML shell | * Implements the XML shell |
* This allow to load, validate, view, modify and save a document |
* This allow to load, validate, view, modify and save a document |
* using a environment similar to a UNIX commandline. |
* using a environment similar to a UNIX commandline. |
*/ |
*/ |
Line 2837 xmlShell(xmlDocPtr doc, char *filename, xmlShellReadli
|
Line 2841 xmlShell(xmlDocPtr doc, char *filename, xmlShellReadli
|
while (1) { |
while (1) { |
if (ctxt->node == (xmlNodePtr) ctxt->doc) |
if (ctxt->node == (xmlNodePtr) ctxt->doc) |
snprintf(prompt, sizeof(prompt), "%s > ", "/"); |
snprintf(prompt, sizeof(prompt), "%s > ", "/"); |
|
else if ((ctxt->node != NULL) && (ctxt->node->name) && |
|
(ctxt->node->ns) && (ctxt->node->ns->prefix)) |
|
snprintf(prompt, sizeof(prompt), "%s:%s > ", |
|
(ctxt->node->ns->prefix), ctxt->node->name); |
else if ((ctxt->node != NULL) && (ctxt->node->name)) |
else if ((ctxt->node != NULL) && (ctxt->node->name)) |
snprintf(prompt, sizeof(prompt), "%s > ", ctxt->node->name); |
snprintf(prompt, sizeof(prompt), "%s > ", ctxt->node->name); |
else |
else |
Line 2911 xmlShell(xmlDocPtr doc, char *filename, xmlShellReadli
|
Line 2919 xmlShell(xmlDocPtr doc, char *filename, xmlShellReadli
|
fprintf(ctxt->output, "\t the default namespace if any uses 'defaultns' prefix\n"); |
fprintf(ctxt->output, "\t the default namespace if any uses 'defaultns' prefix\n"); |
#endif /* LIBXML_XPATH_ENABLED */ |
#endif /* LIBXML_XPATH_ENABLED */ |
fprintf(ctxt->output, "\tpwd display current working directory\n"); |
fprintf(ctxt->output, "\tpwd display current working directory\n"); |
|
fprintf(ctxt->output, "\twhereis display absolute path of [path] or current working directory\n"); |
fprintf(ctxt->output, "\tquit leave shell\n"); |
fprintf(ctxt->output, "\tquit leave shell\n"); |
#ifdef LIBXML_OUTPUT_ENABLED |
#ifdef LIBXML_OUTPUT_ENABLED |
fprintf(ctxt->output, "\tsave [name] save this document to name or the original name\n"); |
fprintf(ctxt->output, "\tsave [name] save this document to name or the original name\n"); |
Line 2960 xmlShell(xmlDocPtr doc, char *filename, xmlShellReadli
|
Line 2969 xmlShell(xmlDocPtr doc, char *filename, xmlShellReadli
|
if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL)) |
if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL)) |
fprintf(ctxt->output, "%s\n", dir); |
fprintf(ctxt->output, "%s\n", dir); |
} else if (!strcmp(command, "du")) { |
} else if (!strcmp(command, "du")) { |
xmlShellDu(ctxt, NULL, ctxt->node, NULL); | if (arg[0] == 0) { |
| xmlShellDu(ctxt, NULL, ctxt->node, NULL); |
| } else { |
| ctxt->pctxt->node = ctxt->node; |
| #ifdef LIBXML_XPATH_ENABLED |
| ctxt->pctxt->node = ctxt->node; |
| list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt); |
| #else |
| list = NULL; |
| #endif /* LIBXML_XPATH_ENABLED */ |
| if (list != NULL) { |
| switch (list->type) { |
| case XPATH_UNDEFINED: |
| xmlGenericError(xmlGenericErrorContext, |
| "%s: no such node\n", arg); |
| break; |
| case XPATH_NODESET:{ |
| int indx; |
| |
| if (list->nodesetval == NULL) |
| break; |
| |
| for (indx = 0; |
| indx < list->nodesetval->nodeNr; |
| indx++) |
| xmlShellDu(ctxt, NULL, |
| list->nodesetval-> |
| nodeTab[indx], NULL); |
| break; |
| } |
| case XPATH_BOOLEAN: |
| xmlGenericError(xmlGenericErrorContext, |
| "%s is a Boolean\n", arg); |
| break; |
| case XPATH_NUMBER: |
| xmlGenericError(xmlGenericErrorContext, |
| "%s is a number\n", arg); |
| break; |
| case XPATH_STRING: |
| xmlGenericError(xmlGenericErrorContext, |
| "%s is a string\n", arg); |
| break; |
| case XPATH_POINT: |
| xmlGenericError(xmlGenericErrorContext, |
| "%s is a point\n", arg); |
| break; |
| case XPATH_RANGE: |
| xmlGenericError(xmlGenericErrorContext, |
| "%s is a range\n", arg); |
| break; |
| case XPATH_LOCATIONSET: |
| xmlGenericError(xmlGenericErrorContext, |
| "%s is a range\n", arg); |
| break; |
| case XPATH_USERS: |
| xmlGenericError(xmlGenericErrorContext, |
| "%s is user-defined\n", arg); |
| break; |
| case XPATH_XSLT_TREE: |
| xmlGenericError(xmlGenericErrorContext, |
| "%s is an XSLT value tree\n", |
| arg); |
| break; |
| } |
| #ifdef LIBXML_XPATH_ENABLED |
| xmlXPathFreeObject(list); |
| #endif |
| } else { |
| xmlGenericError(xmlGenericErrorContext, |
| "%s: no such node\n", arg); |
| } |
| ctxt->pctxt->node = NULL; |
| } |
} else if (!strcmp(command, "base")) { |
} else if (!strcmp(command, "base")) { |
xmlShellBase(ctxt, NULL, ctxt->node, NULL); |
xmlShellBase(ctxt, NULL, ctxt->node, NULL); |
} else if (!strcmp(command, "set")) { |
} else if (!strcmp(command, "set")) { |
Line 3032 xmlShell(xmlDocPtr doc, char *filename, xmlShellReadli
|
Line 3113 xmlShell(xmlDocPtr doc, char *filename, xmlShellReadli
|
xmlShellList(ctxt, NULL, |
xmlShellList(ctxt, NULL, |
list->nodesetval-> |
list->nodesetval-> |
nodeTab[indx], NULL); |
nodeTab[indx], NULL); |
|
} |
|
break; |
|
} |
|
case XPATH_BOOLEAN: |
|
xmlGenericError(xmlGenericErrorContext, |
|
"%s is a Boolean\n", arg); |
|
break; |
|
case XPATH_NUMBER: |
|
xmlGenericError(xmlGenericErrorContext, |
|
"%s is a number\n", arg); |
|
break; |
|
case XPATH_STRING: |
|
xmlGenericError(xmlGenericErrorContext, |
|
"%s is a string\n", arg); |
|
break; |
|
case XPATH_POINT: |
|
xmlGenericError(xmlGenericErrorContext, |
|
"%s is a point\n", arg); |
|
break; |
|
case XPATH_RANGE: |
|
xmlGenericError(xmlGenericErrorContext, |
|
"%s is a range\n", arg); |
|
break; |
|
case XPATH_LOCATIONSET: |
|
xmlGenericError(xmlGenericErrorContext, |
|
"%s is a range\n", arg); |
|
break; |
|
case XPATH_USERS: |
|
xmlGenericError(xmlGenericErrorContext, |
|
"%s is user-defined\n", arg); |
|
break; |
|
case XPATH_XSLT_TREE: |
|
xmlGenericError(xmlGenericErrorContext, |
|
"%s is an XSLT value tree\n", |
|
arg); |
|
break; |
|
} |
|
#ifdef LIBXML_XPATH_ENABLED |
|
xmlXPathFreeObject(list); |
|
#endif |
|
} else { |
|
xmlGenericError(xmlGenericErrorContext, |
|
"%s: no such node\n", arg); |
|
} |
|
ctxt->pctxt->node = NULL; |
|
} |
|
} else if (!strcmp(command, "whereis")) { |
|
char dir[500]; |
|
|
|
if (arg[0] == 0) { |
|
if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL)) |
|
fprintf(ctxt->output, "%s\n", dir); |
|
} else { |
|
ctxt->pctxt->node = ctxt->node; |
|
#ifdef LIBXML_XPATH_ENABLED |
|
list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt); |
|
#else |
|
list = NULL; |
|
#endif /* LIBXML_XPATH_ENABLED */ |
|
if (list != NULL) { |
|
switch (list->type) { |
|
case XPATH_UNDEFINED: |
|
xmlGenericError(xmlGenericErrorContext, |
|
"%s: no such node\n", arg); |
|
break; |
|
case XPATH_NODESET:{ |
|
int indx; |
|
|
|
if (list->nodesetval == NULL) |
|
break; |
|
|
|
for (indx = 0; |
|
indx < list->nodesetval->nodeNr; |
|
indx++) { |
|
if (!xmlShellPwd(ctxt, dir, list->nodesetval-> |
|
nodeTab[indx], NULL)) |
|
fprintf(ctxt->output, "%s\n", dir); |
} |
} |
break; |
break; |
} |
} |