⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debugxml.c

📁 libxml,在UNIX/LINUX下非常重要的一个库,为XML相关应用提供方便.目前上载的是最新版本,若要取得最新版本,请参考里面的readme.
💻 C
📖 第 1 页 / 共 5 页
字号:
		    xmlGenericError(xmlGenericErrorContext,				    "Node set\n");#endif /* LIBXML_OUTPUT_ENABLED */                }            case XPATH_BOOLEAN:                xmlGenericError(xmlGenericErrorContext,                                "Is a Boolean:%s\n",                                xmlBoolToText(list->boolval));                break;            case XPATH_NUMBER:                xmlGenericError(xmlGenericErrorContext,                                "Is a number:%0g\n", list->floatval);                break;            case XPATH_STRING:                xmlGenericError(xmlGenericErrorContext,                                "Is a string:%s\n", list->stringval);                break;            default:                xmlShellPrintXPathError(list->type, NULL);        }    }}/** * xmlShellPrintXPathResult: * @list: a valid result generated by an xpath evaluation * * Prints result to the output FILE */voidxmlShellPrintXPathResult(xmlXPathObjectPtr list){    xmlShellPrintXPathResultCtxt(NULL, list);}/** * xmlShellList: * @ctxt:  the shell context * @arg:  unused * @node:  a node * @node2:  unused * * Implements the XML shell function "ls" * Does an Unix like listing of the given node (like a directory) * * Returns 0 */intxmlShellList(xmlShellCtxtPtr ctxt,             char *arg ATTRIBUTE_UNUSED, xmlNodePtr node,             xmlNodePtr node2 ATTRIBUTE_UNUSED){    xmlNodePtr cur;    if (!ctxt)        return (0);    if (node == NULL) {	fprintf(ctxt->output, "NULL\n");	return (0);    }    if ((node->type == XML_DOCUMENT_NODE) ||        (node->type == XML_HTML_DOCUMENT_NODE)) {        cur = ((xmlDocPtr) node)->children;    } else if (node->type == XML_NAMESPACE_DECL) {        xmlLsOneNode(ctxt->output, node);        return (0);    } else if (node->children != NULL) {        cur = node->children;    } else {        xmlLsOneNode(ctxt->output, node);        return (0);    }    while (cur != NULL) {        xmlLsOneNode(ctxt->output, cur);        cur = cur->next;    }    return (0);}/** * xmlShellBase: * @ctxt:  the shell context * @arg:  unused * @node:  a node * @node2:  unused * * Implements the XML shell function "base" * dumps the current XML base of the node * * Returns 0 */intxmlShellBase(xmlShellCtxtPtr ctxt,             char *arg ATTRIBUTE_UNUSED, xmlNodePtr node,             xmlNodePtr node2 ATTRIBUTE_UNUSED){    xmlChar *base;    if (!ctxt)        return 0;    if (node == NULL) {	fprintf(ctxt->output, "NULL\n");	return (0);    }        base = xmlNodeGetBase(node->doc, node);    if (base == NULL) {        fprintf(ctxt->output, " No base found !!!\n");    } else {        fprintf(ctxt->output, "%s\n", base);        xmlFree(base);    }    return (0);}#ifdef LIBXML_TREE_ENABLED/** * xmlShellSetBase: * @ctxt:  the shell context * @arg:  the new base * @node:  a node * @node2:  unused * * Implements the XML shell function "setbase" * change the current XML base of the node * * Returns 0 */static intxmlShellSetBase(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,             char *arg ATTRIBUTE_UNUSED, xmlNodePtr node,             xmlNodePtr node2 ATTRIBUTE_UNUSED){    xmlNodeSetBase(node, (xmlChar*) arg);    return (0);}#endif#ifdef LIBXML_XPATH_ENABLED/** * xmlShellRegisterNamespace: * @ctxt:  the shell context * @arg:  a string in prefix=nsuri format * @node:  unused * @node2:  unused * * Implements the XML shell function "setns" * register/unregister a prefix=namespace pair * on the XPath context * * Returns 0 on success and a negative value otherwise. */static intxmlShellRegisterNamespace(xmlShellCtxtPtr ctxt, char *arg,      xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr node2 ATTRIBUTE_UNUSED){    xmlChar* nsListDup;    xmlChar* prefix;    xmlChar* href;    xmlChar* next;    nsListDup = xmlStrdup((xmlChar *) arg);    next = nsListDup;    while(next != NULL) {	/* skip spaces */	/*while((*next) == ' ') next++;*/	if((*next) == '\0') break;	/* find prefix */	prefix = next;	next = (xmlChar*)xmlStrchr(next, '=');	if(next == NULL) {	    fprintf(ctxt->output, "setns: prefix=[nsuri] required\n");	    xmlFree(nsListDup);	    return(-1);	}	*(next++) = '\0';	/* find href */	href = next;	next = (xmlChar*)xmlStrchr(next, ' ');	if(next != NULL) {	    *(next++) = '\0';	}	/* do register namespace */	if(xmlXPathRegisterNs(ctxt->pctxt, prefix, href) != 0) {	    fprintf(ctxt->output,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", prefix, href);	    xmlFree(nsListDup);	    return(-1);	}    }    xmlFree(nsListDup);    return(0);}#endif/** * xmlShellGrep: * @ctxt:  the shell context * @arg:  the string or regular expression to find * @node:  a node * @node2:  unused * * Implements the XML shell function "grep" * dumps informations about the node (namespace, attributes, content). * * Returns 0 */static intxmlShellGrep(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,            char *arg, xmlNodePtr node, xmlNodePtr node2 ATTRIBUTE_UNUSED){    if (!ctxt)        return (0);    if (node == NULL)	return (0);    if (arg == NULL)	return (0);#ifdef LIBXML_REGEXP_ENABLED    if ((xmlStrchr((xmlChar *) arg, '?')) ||	(xmlStrchr((xmlChar *) arg, '*')) ||	(xmlStrchr((xmlChar *) arg, '.')) ||	(xmlStrchr((xmlChar *) arg, '['))) {    }#endif    while (node != NULL) {        if (node->type == XML_COMMENT_NODE) {	    if (xmlStrstr(node->content, (xmlChar *) arg)) {		fprintf(ctxt->output, "%s : ", xmlGetNodePath(node));                xmlShellList(ctxt, NULL, node, NULL);	    }        } else if (node->type == XML_TEXT_NODE) {	    if (xmlStrstr(node->content, (xmlChar *) arg)) {		fprintf(ctxt->output, "%s : ", xmlGetNodePath(node->parent));                xmlShellList(ctxt, NULL, node->parent, NULL);	    }        }        /*         * Browse the full subtree, deep first         */        if ((node->type == XML_DOCUMENT_NODE) ||            (node->type == XML_HTML_DOCUMENT_NODE)) {            node = ((xmlDocPtr) node)->children;        } else if ((node->children != NULL)                   && (node->type != XML_ENTITY_REF_NODE)) {            /* deep first */            node = node->children;        } else if (node->next != NULL) {            /* then siblings */            node = node->next;        } else {            /* go up to parents->next if needed */            while (node != NULL) {                if (node->parent != NULL) {                    node = node->parent;                }                if (node->next != NULL) {                    node = node->next;                    break;                }                if (node->parent == NULL) {                    node = NULL;                    break;                }            }	}    }    return (0);}/** * xmlShellDir: * @ctxt:  the shell context * @arg:  unused * @node:  a node * @node2:  unused * * Implements the XML shell function "dir" * dumps informations about the node (namespace, attributes, content). * * Returns 0 */intxmlShellDir(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,            char *arg ATTRIBUTE_UNUSED, xmlNodePtr node,            xmlNodePtr node2 ATTRIBUTE_UNUSED){    if (!ctxt)        return (0);    if (node == NULL) {	fprintf(ctxt->output, "NULL\n");	return (0);    }        if ((node->type == XML_DOCUMENT_NODE) ||        (node->type == XML_HTML_DOCUMENT_NODE)) {        xmlDebugDumpDocumentHead(ctxt->output, (xmlDocPtr) node);    } else if (node->type == XML_ATTRIBUTE_NODE) {        xmlDebugDumpAttr(ctxt->output, (xmlAttrPtr) node, 0);    } else {        xmlDebugDumpOneNode(ctxt->output, node, 0);    }    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 intxmlShellSetContent(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: * @ctxt:  the shell context * @schemas:  the path to the Relax-NG schemas * @node:  a node * @node2:  unused * * Implements the XML shell function "relaxng" * validating the instance against a Relax-NG schemas * * Returns 0 */static intxmlShellRNGValidate(xmlShellCtxtPtr sctxt, char *schemas,            xmlNodePtr node ATTRIBUTE_UNUSED,	    xmlNodePtr node2 ATTRIBUTE_UNUSED){    xmlRelaxNGPtr relaxngschemas;    xmlRelaxNGParserCtxtPtr ctxt;    xmlRelaxNGValidCtxtPtr vctxt;    int ret;    ctxt = xmlRelaxNGNewParserCtxt(schemas);    xmlRelaxNGSetParserErrors(ctxt,	    (xmlRelaxNGValidityErrorFunc) fprintf,	    (xmlRelaxNGValidityWarningFunc) fprintf,	    stderr);    relaxngschemas = xmlRelaxNGParse(ctxt);    xmlRelaxNGFreeParserCtxt(ctxt);    if (relaxngschemas == NULL) {	xmlGenericError(xmlGenericErrorContext,		"Relax-NG schema %s failed to compile\n", schemas);	return(-1);    }    vctxt = xmlRelaxNGNewValidCtxt(relaxngschemas);    xmlRelaxNGSetValidErrors(vctxt,	    (xmlRelaxNGValidityErrorFunc) fprintf,	    (xmlRelaxNGValidityWarningFunc) fprintf,	    stderr);    ret = xmlRelaxNGValidateDoc(vctxt, sctxt->doc);    if (ret == 0) {	fprintf(stderr, "%s validates\n", sctxt->filename);    } else if (ret > 0) {	fprintf(stderr, "%s fails to validate\n", sctxt->filename);    } else {	fprintf(stderr, "%s validation generated an internal error\n",	       sctxt->filename);    }    xmlRelaxNGFreeValidCtxt(vctxt);    if (relaxngschemas != NULL)	xmlRelaxNGFree(relaxngschemas);    return(0);}#endif#ifdef LIBXML_OUTPUT_ENABLED/** * xmlShellCat: * @ctxt:  the shell context * @arg:  unused * @node:  a node * @node2:  unused * * Implements the XML shell function "cat" * dumps the serialization node content (XML or HTML). * * Returns 0 */intxmlShellCat(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_UNUSED,            xmlNodePtr node, xmlNodePtr node2 ATTRIBUTE_UNUSED){    if (!ctxt)        return (0);    if (node == NULL) {	fprintf(ctxt->output, "NULL\n");	return (0);    }        if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) {#ifdef LIBXML_HTML_ENABLED        if (node->type == XML_HTML_DOCUMENT_NODE)            htmlDocDump(ctxt->output, (htmlDocPtr) node);        else            htmlNodeDumpFile(ctxt->output, ctxt->doc, node);#else        if (node->type == XML_DOCUMENT_NODE)            xmlDocDump(ctxt->output, (xmlDocPtr) node);        else            xmlElemDump(ctxt->output, ctxt->doc, node);#endif /* LIBXML_HTML_ENABLED */    } else {        if (node->type == XML_DOCUMENT_NODE)            xmlDocDump(ctxt->output, (xmlDocPtr) node);        else            xmlElemDump(ctxt->output, ctxt->doc, node);    }    fprintf(ctxt->output, "\n");    return (0);}#endif /* LIBXML_OUTPUT_ENABLED *//** * xmlShellLoad: * @ctxt:  the shell context * @filename:  the file name * @node:  unused * @node2:  unused * * Implements the XML shell function "load" * loads a new document specified by the filename * * Returns 0 or -1 if loading failed */intxmlShellLoad(xmlShellCtxtPtr ctxt, char *filename,             xmlNodePtr node ATTRIBUTE_UNUSED,             xmlNodePtr node2 ATTRIBUTE_UNUSED){    xmlDocPtr doc;    int html = 0;    if ((ctxt == NULL) || (f

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -