summaryrefslogtreecommitdiff
path: root/debugXML.c
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2004-09-10 05:26:00 +0000
committerMike Hommey <mh@glandium.org>2004-09-10 05:26:00 +0000
commit09deb06614c3408ec0816a3c88920138bae2083c (patch)
treea1b841a7dc28eecb98ca361c9371ecd1449a1908 /debugXML.c
parentc14c53a3645d81281058d4bb4cff24fa8d6faf33 (diff)
downloadlibxml2-09deb06614c3408ec0816a3c88920138bae2083c.tar.gz
Load /tmp/tmp.BmUFjT/libxml2-2.6.13 intoupstream/2.6.13
packages/libxml2/branches/upstream/current.
Diffstat (limited to 'debugXML.c')
-rw-r--r--debugXML.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/debugXML.c b/debugXML.c
index 768010d..71a8712 100644
--- a/debugXML.c
+++ b/debugXML.c
@@ -1733,6 +1733,51 @@ xmlShellDir(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
return (0);
}
+/**
+ * xmlShellSetContent:
+ * @ctxt: the shell context
+ * @value: the content as a string
+ * @node: a node
+ * @node2: unused
+ *
+ * Implements the XML shell function "dir"
+ * dumps informations about the node (namespace, attributes, content).
+ *
+ * Returns 0
+ */
+static int
+xmlShellSetContent(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
+ char *value, xmlNodePtr node,
+ xmlNodePtr node2 ATTRIBUTE_UNUSED)
+{
+ xmlNodePtr results;
+ xmlParserErrors ret;
+
+ if (!ctxt)
+ return (0);
+ if (node == NULL) {
+ fprintf(ctxt->output, "NULL\n");
+ return (0);
+ }
+ if (value == NULL) {
+ fprintf(ctxt->output, "NULL\n");
+ return (0);
+ }
+
+ ret = xmlParseInNodeContext(node, value, strlen(value), 0, &results);
+ if (ret == XML_ERR_OK) {
+ if (node->children != NULL) {
+ xmlFreeNodeList(node->children);
+ node->children = NULL;
+ node->last = NULL;
+ }
+ xmlAddChildList(node, results);
+ } else {
+ fprintf(ctxt->output, "failed to parse content\n");
+ }
+ return (0);
+}
+
#ifdef LIBXML_SCHEMAS_ENABLED
/**
* xmlShellRNGValidate:
@@ -2304,6 +2349,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
fprintf(ctxt->output, "\tfree display memory usage\n");
fprintf(ctxt->output, "\tload [name] load a new document with name\n");
fprintf(ctxt->output, "\tls [path] list contents of path or the current directory\n");
+ fprintf(ctxt->output, "\tset xml_fragment replace the current node content with the fragment parsed in context\n");
#ifdef LIBXML_XPATH_ENABLED
fprintf(ctxt->output, "\txpath expr evaluate the XPath expression in that context and print the result\n");
fprintf(ctxt->output, "\tsetns nsreg register a namespace to a prefix in the XPath evaluation context\n");
@@ -2358,6 +2404,8 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlShellDu(ctxt, NULL, ctxt->node, NULL);
} else if (!strcmp(command, "base")) {
xmlShellBase(ctxt, NULL, ctxt->node, NULL);
+ } else if (!strcmp(command, "set")) {
+ xmlShellSetContent(ctxt, arg, ctxt->node, NULL);
#ifdef LIBXML_XPATH_ENABLED
} else if (!strcmp(command, "setns")) {
if (arg[0] == 0) {