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

📄 debugxml.c.svn-base

📁 这是一个用于解析xml文件的类库。使用这个类库
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
    if (ent == NULL) {	fprintf(output, "Entity is NULL\n");	return;    }    switch (ent->etype) {        case XML_INTERNAL_GENERAL_ENTITY:	    fprintf(output, "INTERNAL_GENERAL_ENTITY ");	    break;        case XML_EXTERNAL_GENERAL_PARSED_ENTITY:	    fprintf(output, "EXTERNAL_GENERAL_PARSED_ENTITY ");	    break;        case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:	    fprintf(output, "EXTERNAL_GENERAL_UNPARSED_ENTITY ");	    break;        case XML_INTERNAL_PARAMETER_ENTITY:	    fprintf(output, "INTERNAL_PARAMETER_ENTITY ");	    break;        case XML_EXTERNAL_PARAMETER_ENTITY:	    fprintf(output, "EXTERNAL_PARAMETER_ENTITY ");	    break;	default:	    fprintf(output, "ENTITY_%d ! ", ent->etype);    }    fprintf(output, "%s\n", ent->name);    if (ent->ExternalID) {        fprintf(output, shift);        fprintf(output, "ExternalID=%s\n", ent->ExternalID);    }    if (ent->SystemID) {        fprintf(output, shift);        fprintf(output, "SystemID=%s\n", ent->SystemID);    }    if (ent->URI) {        fprintf(output, shift);        fprintf(output, "URI=%s\n", ent->URI);    }    if (ent->content) {        fprintf(output, shift);	fprintf(output, "content=");	xmlDebugDumpString(output, ent->content);	fprintf(output, "\n");    }}/** * xmlDebugDumpAttr: * @output:  the FILE * for the output * @attr:  the attribute * @depth:  the indentation level. * * Dumps debug information for the attribute */voidxmlDebugDumpAttr(FILE *output, xmlAttrPtr attr, int depth) {    int i;    char shift[100];    for (i = 0;((i < depth) && (i < 25));i++)        shift[2 * i] = shift[2 * i + 1] = ' ';    shift[2 * i] = shift[2 * i + 1] = 0;    fprintf(output, shift);        if (attr == NULL) {	fprintf(output, "Attr is NULL");	return;    }    fprintf(output, "ATTRIBUTE ");    xmlDebugDumpString(output, attr->name);    fprintf(output, "\n");    if (attr->children != NULL)         xmlDebugDumpNodeList(output, attr->children, depth + 1);    /*     * Do a bit of checking     */    if (attr->parent == NULL)	fprintf(output, "PBM: Attr has no parent\n");    if (attr->doc == NULL)	fprintf(output, "PBM: Attr has no doc\n");    if ((attr->parent != NULL) && (attr->doc != attr->parent->doc))	fprintf(output, "PBM: Attr doc differs from parent's one\n");    if (attr->prev == NULL) {	if ((attr->parent != NULL) && (attr->parent->properties != attr))	    fprintf(output, "PBM: Attr has no prev and not first of list\n");    } else {	if (attr->prev->next != attr)	    fprintf(output, "PBM: Attr prev->next : back link wrong\n");    }    if (attr->next != NULL) {	if (attr->next->prev != attr)	    fprintf(output, "PBM: Attr next->prev : forward link wrong\n");    }}/** * xmlDebugDumpAttrList: * @output:  the FILE * for the output * @attr:  the attribute list * @depth:  the indentation level. * * Dumps debug information for the attribute list */voidxmlDebugDumpAttrList(FILE * output, xmlAttrPtr attr, int depth){    if (output == NULL)	output = stdout;    while (attr != NULL) {        xmlDebugDumpAttr(output, attr, depth);        attr = attr->next;    }}/** * xmlDebugDumpOneNode: * @output:  the FILE * for the output * @node:  the node * @depth:  the indentation level. * * Dumps debug information for the element node, it is not recursive */voidxmlDebugDumpOneNode(FILE * output, xmlNodePtr node, int depth){    int i;    char shift[100];    if (output == NULL)	output = stdout;    for (i = 0; ((i < depth) && (i < 25)); i++)        shift[2 * i] = shift[2 * i + 1] = ' ';    shift[2 * i] = shift[2 * i + 1] = 0;    if (node == NULL) {	fprintf(output, shift);	fprintf(output, "node is NULL\n");	return;    }    switch (node->type) {        case XML_ELEMENT_NODE:            fprintf(output, shift);            fprintf(output, "ELEMENT ");            if ((node->ns != NULL) && (node->ns->prefix != NULL)) {                xmlDebugDumpString(output, node->ns->prefix);                fprintf(output, ":");            }            xmlDebugDumpString(output, node->name);            fprintf(output, "\n");            break;        case XML_ATTRIBUTE_NODE:            fprintf(output, shift);            fprintf(output, "Error, ATTRIBUTE found here\n");            break;        case XML_TEXT_NODE:            fprintf(output, shift);	    if (node->name == (const xmlChar *) xmlStringTextNoenc)		fprintf(output, "TEXT no enc\n");	    else		fprintf(output, "TEXT\n");            break;        case XML_CDATA_SECTION_NODE:            fprintf(output, shift);            fprintf(output, "CDATA_SECTION\n");            break;        case XML_ENTITY_REF_NODE:            fprintf(output, shift);            fprintf(output, "ENTITY_REF(%s)\n", node->name);            break;        case XML_ENTITY_NODE:            fprintf(output, shift);            fprintf(output, "ENTITY\n");            break;        case XML_PI_NODE:            fprintf(output, shift);            fprintf(output, "PI %s\n", node->name);            break;        case XML_COMMENT_NODE:            fprintf(output, shift);            fprintf(output, "COMMENT\n");            break;        case XML_DOCUMENT_NODE:        case XML_HTML_DOCUMENT_NODE:            fprintf(output, shift);            fprintf(output, "Error, DOCUMENT found here\n");            break;        case XML_DOCUMENT_TYPE_NODE:            fprintf(output, shift);            fprintf(output, "DOCUMENT_TYPE\n");            break;        case XML_DOCUMENT_FRAG_NODE:            fprintf(output, shift);            fprintf(output, "DOCUMENT_FRAG\n");            break;        case XML_NOTATION_NODE:            fprintf(output, shift);            fprintf(output, "NOTATION\n");            break;        case XML_DTD_NODE:            xmlDebugDumpDtdNode(output, (xmlDtdPtr) node, depth);            return;        case XML_ELEMENT_DECL:            xmlDebugDumpElemDecl(output, (xmlElementPtr) node, depth);            return;        case XML_ATTRIBUTE_DECL:            xmlDebugDumpAttrDecl(output, (xmlAttributePtr) node, depth);            return;        case XML_ENTITY_DECL:            xmlDebugDumpEntityDecl(output, (xmlEntityPtr) node, depth);            return;        case XML_NAMESPACE_DECL:            xmlDebugDumpNamespace(output, (xmlNsPtr) node, depth);            return;        case XML_XINCLUDE_START:            fprintf(output, shift);            fprintf(output, "INCLUDE START\n");            return;        case XML_XINCLUDE_END:            fprintf(output, shift);            fprintf(output, "INCLUDE END\n");            return;        default:            fprintf(output, shift);            fprintf(output, "NODE_%d !!!\n", node->type);            return;    }    if (node->doc == NULL) {        fprintf(output, shift);        fprintf(output, "doc == NULL !!!\n");    }    if (node->nsDef != NULL)        xmlDebugDumpNamespaceList(output, node->nsDef, depth + 1);    if (node->properties != NULL)        xmlDebugDumpAttrList(output, node->properties, depth + 1);    if (node->type != XML_ENTITY_REF_NODE) {        if ((node->type != XML_ELEMENT_NODE) && (node->content != NULL)) {            shift[2 * i] = shift[2 * i + 1] = ' ';            shift[2 * i + 2] = shift[2 * i + 3] = 0;            fprintf(output, shift);            fprintf(output, "content=");            xmlDebugDumpString(output, node->content);            fprintf(output, "\n");        }    } else {        xmlEntityPtr ent;        ent = xmlGetDocEntity(node->doc, node->name);        if (ent != NULL)            xmlDebugDumpEntity(output, ent, depth + 1);    }    /*     * Do a bit of checking     */    if (node->parent == NULL)        fprintf(output, "PBM: Node has no parent\n");    if (node->doc == NULL)        fprintf(output, "PBM: Node has no doc\n");    if ((node->parent != NULL) && (node->doc != node->parent->doc))        fprintf(output, "PBM: Node doc differs from parent's one\n");    if (node->prev == NULL) {        if ((node->parent != NULL) && (node->parent->children != node))            fprintf(output,                    "PBM: Node has no prev and not first of list\n");    } else {        if (node->prev->next != node)            fprintf(output, "PBM: Node prev->next : back link wrong\n");    }    if (node->next == NULL) {        if ((node->parent != NULL) && (node->parent->last != node))            fprintf(output,                    "PBM: Node has no next and not last of list\n");    } else {        if (node->next->prev != node)            fprintf(output, "PBM: Node next->prev : forward link wrong\n");    }}/** * xmlDebugDumpNode: * @output:  the FILE * for the output * @node:  the node * @depth:  the indentation level. * * Dumps debug information for the element node, it is recursive */voidxmlDebugDumpNode(FILE * output, xmlNodePtr node, int depth){    if (output == NULL)	output = stdout;    if (node == NULL) {	int i;	char shift[100];    		for (i = 0; ((i < depth) && (i < 25)); i++)	    shift[2 * i] = shift[2 * i + 1] = ' ';	shift[2 * i] = shift[2 * i + 1] = 0;		fprintf(output, shift);	fprintf(output, "node is NULL\n");	return;    }	    xmlDebugDumpOneNode(output, node, depth);    if ((node->children != NULL) && (node->type != XML_ENTITY_REF_NODE))        xmlDebugDumpNodeList(output, node->children, depth + 1);}/** * xmlDebugDumpNodeList: * @output:  the FILE * for the output * @node:  the node list * @depth:  the indentation level. * * Dumps debug information for the list of element node, it is recursive */voidxmlDebugDumpNodeList(FILE * output, xmlNodePtr node, int depth){    if (output == NULL)	output = stdout;    while (node != NULL) {        xmlDebugDumpNode(output, node, depth);        node = node->next;    }}/** * xmlDebugDumpDocumentHead: * @output:  the FILE * for the output * @doc:  the document * * Dumps debug information cncerning the document, not recursive */voidxmlDebugDumpDocumentHead(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->name != NULL) {        fprintf(output, "name=");        xmlDebugDumpString(output, BAD_CAST doc->name);        fprintf(output, "\n");    }    if (doc->version != NULL) {        fprintf(output, "version=");        xmlDebugDumpString(output, doc->version);        fprintf(output, "\n");    }    if (doc->encoding != NULL) {        fprintf(output, "encoding=");        xmlDebugDumpString(output, doc->encoding);        fprintf(output, "\n");    }    if (doc->URL != NULL) {        fprintf(output, "URL=");        xmlDebugDumpString(output, doc->URL);        fprintf(output, "\n");    }    if (doc->standalone)        fprintf(output, "standalone=true\n");    if (doc->oldNs != NULL)        xmlDebugDumpNamespaceList(output, doc->oldNs, 0);}/** * xmlDebugDumpDocument: * @output:  the FILE * for the output * @doc:  the document * * Dumps debug information for the document, it's recursive */voidxmlDebugDumpDocument(FILE * output, xmlDocPtr doc){    if (output == NULL)        output = stdout;    if (doc == NULL) {        fprintf(output, "DOCUMENT == NULL !\n");        return;    }    xmlDebugDumpDocumentHead(output, doc);    if (((doc->type == XML_DOCUMENT_NODE) ||         (doc->type == XML_HTML_DOCUMENT_NODE)) && (doc->children != NULL))        xmlDebugDumpNodeList(output, doc->children, 1);}/** * xmlDebugDumpDTD: * @output:  the FILE * for the output * @dtd:  the DTD * * Dumps debug information for the DTD */voidxmlDebugDumpDTD(FILE * output, xmlDtdPtr dtd){    if (output == NULL)	output = stdout;    if (dtd == NULL) {	fprintf(output, "DTD is NULL\n");        return;    }    if (dtd->type != XML_DTD_NODE) {        fprintf(output, "PBM: not a DTD\n");        return;    }    if (dtd->name != NULL)        fprintf(output, "DTD(%s)", dtd->name);    else        fprintf(output, "DTD");    if (dtd->ExternalID != NULL)        fprintf(output, ", PUBLIC %s", dtd->ExternalID);    if (dtd->SystemID != NULL)

⌨️ 快捷键说明

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