version 1.1.1.1, 2012/02/21 23:37:57
|
version 1.1.1.2, 2013/07/22 01:22:19
|
Line 1724 xmlLsOneNode(FILE *output, xmlNodePtr node) {
|
Line 1724 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 2696 xmlShellDu(xmlShellCtxtPtr ctxt,
|
Line 2699 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 2837 xmlShell(xmlDocPtr doc, char *filename, xmlShellReadli
|
Line 2842 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 2920 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 2970 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 3114 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; |
} |
} |