📄 debugxml.c.svn-base
字号:
fprintf(output, ", SYSTEM %s", dtd->SystemID); fprintf(output, "\n"); /* * Do a bit of checking */ if ((dtd->parent != NULL) && (dtd->doc != dtd->parent->doc)) fprintf(output, "PBM: DTD doc differs from parent's one\n"); if (dtd->prev == NULL) { if ((dtd->parent != NULL) && (dtd->parent->children != (xmlNodePtr) dtd)) fprintf(output, "PBM: DTD has no prev and not first of list\n"); } else { if (dtd->prev->next != (xmlNodePtr) dtd) fprintf(output, "PBM: DTD prev->next : back link wrong\n"); } if (dtd->next == NULL) { if ((dtd->parent != NULL) && (dtd->parent->last != (xmlNodePtr) dtd)) fprintf(output, "PBM: DTD has no next and not last of list\n"); } else { if (dtd->next->prev != (xmlNodePtr) dtd) fprintf(output, "PBM: DTD next->prev : forward link wrong\n"); } if (dtd->children == NULL) fprintf(output, " DTD is empty\n"); else xmlDebugDumpNodeList(output, dtd->children, 1);}static voidxmlDebugDumpEntityCallback(xmlEntityPtr cur, FILE *output) { if (cur == NULL) { fprintf(output, "Entity is NULL"); return; } fprintf(output, "%s : ", cur->name); switch (cur->etype) { case XML_INTERNAL_GENERAL_ENTITY: fprintf(output, "INTERNAL GENERAL, "); break; case XML_EXTERNAL_GENERAL_PARSED_ENTITY: fprintf(output, "EXTERNAL PARSED, "); break; case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY: fprintf(output, "EXTERNAL UNPARSED, "); break; case XML_INTERNAL_PARAMETER_ENTITY: fprintf(output, "INTERNAL PARAMETER, "); break; case XML_EXTERNAL_PARAMETER_ENTITY: fprintf(output, "EXTERNAL PARAMETER, "); break; default: fprintf(output, "UNKNOWN TYPE %d", cur->etype); } if (cur->ExternalID != NULL) fprintf(output, "ID \"%s\"", cur->ExternalID); if (cur->SystemID != NULL) fprintf(output, "SYSTEM \"%s\"", cur->SystemID); if (cur->orig != NULL) fprintf(output, "\n orig \"%s\"", cur->orig); if ((cur->type != XML_ELEMENT_NODE) && (cur->content != NULL)) fprintf(output, "\n content \"%s\"", cur->content); fprintf(output, "\n"); }/** * xmlDebugDumpEntities: * @output: the FILE * for the output * @doc: the document * * Dumps debug information for all the entities in use by the document */voidxmlDebugDumpEntities(FILE * output, xmlDocPtr doc){ if (output == NULL) output = stdout; if (doc == NULL) { fprintf(output, "DOCUMENT == NULL !\n"); return; } switch (doc->type) { case XML_ELEMENT_NODE: fprintf(output, "Error, ELEMENT found here "); break; case XML_ATTRIBUTE_NODE: fprintf(output, "Error, ATTRIBUTE found here\n"); break; case XML_TEXT_NODE: fprintf(output, "Error, TEXT\n"); break; case XML_CDATA_SECTION_NODE: fprintf(output, "Error, CDATA_SECTION\n"); break; case XML_ENTITY_REF_NODE: fprintf(output, "Error, ENTITY_REF\n"); break; case XML_ENTITY_NODE: fprintf(output, "Error, ENTITY\n"); break; case XML_PI_NODE: fprintf(output, "Error, PI\n"); break; case XML_COMMENT_NODE: fprintf(output, "Error, COMMENT\n"); break; case XML_DOCUMENT_NODE: fprintf(output, "DOCUMENT\n"); break; case XML_HTML_DOCUMENT_NODE: fprintf(output, "HTML DOCUMENT\n"); break; case XML_DOCUMENT_TYPE_NODE: fprintf(output, "Error, DOCUMENT_TYPE\n"); break; case XML_DOCUMENT_FRAG_NODE: fprintf(output, "Error, DOCUMENT_FRAG\n"); break; case XML_NOTATION_NODE: fprintf(output, "Error, NOTATION\n"); break; default: fprintf(output, "NODE_%d\n", doc->type); } if ((doc->intSubset != NULL) && (doc->intSubset->entities != NULL)) { xmlEntitiesTablePtr table = (xmlEntitiesTablePtr) doc->intSubset->entities; fprintf(output, "Entities in internal subset\n"); xmlHashScan(table, (xmlHashScanner) xmlDebugDumpEntityCallback, output); } else fprintf(output, "No entities in internal subset\n"); if ((doc->extSubset != NULL) && (doc->extSubset->entities != NULL)) { xmlEntitiesTablePtr table = (xmlEntitiesTablePtr) doc->extSubset->entities; fprintf(output, "Entities in external subset\n"); xmlHashScan(table, (xmlHashScanner) xmlDebugDumpEntityCallback, output); } else fprintf(output, "No entities in external subset\n");}/** * xmlLsCountNode: * @node: the node to count * * Count the children of @node. * * Returns the number of children of @node. */intxmlLsCountNode(xmlNodePtr node) { int ret = 0; xmlNodePtr list = NULL; if (node == NULL) return(0); switch (node->type) { case XML_ELEMENT_NODE: list = node->children; break; case XML_DOCUMENT_NODE: case XML_HTML_DOCUMENT_NODE:#ifdef LIBXML_DOCB_ENABLED case XML_DOCB_DOCUMENT_NODE:#endif list = ((xmlDocPtr) node)->children; break; case XML_ATTRIBUTE_NODE: list = ((xmlAttrPtr) node)->children; break; case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_PI_NODE: case XML_COMMENT_NODE: if (node->content != NULL) { ret = xmlStrlen(node->content); } break; case XML_ENTITY_REF_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_ENTITY_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_NOTATION_NODE: case XML_DTD_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: case XML_NAMESPACE_DECL: case XML_XINCLUDE_START: case XML_XINCLUDE_END: ret = 1; break; } for (;list != NULL;ret++) list = list->next; return(ret);}/** * xmlLsOneNode: * @output: the FILE * for the output * @node: the node to dump * * Dump to @output the type and name of @node. */voidxmlLsOneNode(FILE *output, xmlNodePtr node) { if (node == NULL) { fprintf(output, "NULL\n"); return; } switch (node->type) { case XML_ELEMENT_NODE: fprintf(output, "-"); break; case XML_ATTRIBUTE_NODE: fprintf(output, "a"); break; case XML_TEXT_NODE: fprintf(output, "t"); break; case XML_CDATA_SECTION_NODE: fprintf(output, "C"); break; case XML_ENTITY_REF_NODE: fprintf(output, "e"); break; case XML_ENTITY_NODE: fprintf(output, "E"); break; case XML_PI_NODE: fprintf(output, "p"); break; case XML_COMMENT_NODE: fprintf(output, "c"); break; case XML_DOCUMENT_NODE: fprintf(output, "d"); break; case XML_HTML_DOCUMENT_NODE: fprintf(output, "h"); break; case XML_DOCUMENT_TYPE_NODE: fprintf(output, "T"); break; case XML_DOCUMENT_FRAG_NODE: fprintf(output, "F"); break; case XML_NOTATION_NODE: fprintf(output, "N"); break; case XML_NAMESPACE_DECL: fprintf(output, "n"); break; default: fprintf(output, "?"); } if (node->type != XML_NAMESPACE_DECL) { if (node->properties != NULL) fprintf(output, "a"); else fprintf(output, "-"); if (node->nsDef != NULL) fprintf(output, "n"); else fprintf(output, "-"); } fprintf(output, " %8d ", xmlLsCountNode(node)); switch (node->type) { case XML_ELEMENT_NODE: if (node->name != NULL) fprintf(output, "%s", (const char *) node->name); break; case XML_ATTRIBUTE_NODE: if (node->name != NULL) fprintf(output, "%s", (const char *) node->name); break; case XML_TEXT_NODE: if (node->content != NULL) { xmlDebugDumpString(output, node->content); } break; case XML_CDATA_SECTION_NODE: break; case XML_ENTITY_REF_NODE: if (node->name != NULL) fprintf(output, "%s", (const char *) node->name); break; case XML_ENTITY_NODE: if (node->name != NULL) fprintf(output, "%s", (const char *) node->name); break; case XML_PI_NODE: if (node->name != NULL) fprintf(output, "%s", (const char *) node->name); break; case XML_COMMENT_NODE: break; case XML_DOCUMENT_NODE: break; case XML_HTML_DOCUMENT_NODE: break; case XML_DOCUMENT_TYPE_NODE: break; case XML_DOCUMENT_FRAG_NODE: break; case XML_NOTATION_NODE: break; case XML_NAMESPACE_DECL: { xmlNsPtr ns = (xmlNsPtr) node; if (ns->prefix == NULL) fprintf(output, "default -> %s", ns->href); else fprintf(output, "%s -> %s", ns->prefix, ns->href); break; } default: if (node->name != NULL) fprintf(output, "%s", (const char *) node->name); } fprintf(output, "\n");}/** * xmlBoolToText: * @boolval: a bool to turn into text * * Convenient way to turn bool into text * * Returns a pointer to either "True" or "False" */const char *xmlBoolToText(int boolval){ if (boolval) return("True"); else return("False");}/**************************************************************** * * * The XML shell related functions * * * ****************************************************************//* * TODO: Improvement/cleanups for the XML shell * - allow to shell out an editor on a subpart * - cleanup function registrations (with help) and calling * - provide registration routines *//** * xmlShellPrintXPathError: * @errorType: valid xpath error id * @arg: the argument that cause xpath to fail * * Print the xpath error to libxml default error channel */voidxmlShellPrintXPathError(int errorType, const char *arg){ const char *default_arg = "Result"; if (!arg) arg = default_arg; switch (errorType) { case XPATH_UNDEFINED: xmlGenericError(xmlGenericErrorContext, "%s: no such node\n", arg); 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; } xmlGenericError(xmlGenericErrorContext, "Try casting the result string function (xpath builtin)\n", arg);}#ifdef LIBXML_OUTPUT_ENABLED/** * xmlShellPrintNodeCtxt: * @ctxt : a non-null shell context * @node : a non-null node to print to the output FILE * * Print node to the output FILE */static voidxmlShellPrintNodeCtxt(xmlShellCtxtPtr ctxt,xmlNodePtr node){ FILE *fp; if (!node) return; if (ctxt == NULL) fp = stdout; else fp = ctxt->output; if (node->type == XML_DOCUMENT_NODE) xmlDocDump(fp, (xmlDocPtr) node); else if (node->type == XML_ATTRIBUTE_NODE) xmlDebugDumpAttrList(fp, (xmlAttrPtr) node, 0); else xmlElemDump(fp, node->doc, node); fprintf(fp, "\n");}/** * xmlShellPrintNode: * @node : a non-null node to print to the output FILE * * Print node to the output FILE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -