From 09deb06614c3408ec0816a3c88920138bae2083c Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 10 Sep 2004 05:26:00 +0000 Subject: Load /tmp/tmp.BmUFjT/libxml2-2.6.13 into packages/libxml2/branches/upstream/current. --- debugXML.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'debugXML.c') 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) { -- cgit v1.2.3