📄 debugxml.c
字号:
/*
* Do a bit of checking
*/
xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) dtd);
}
static void
xmlCtxtDumpAttrDecl(xmlDebugCtxtPtr ctxt, xmlAttributePtr attr)
{
xmlCtxtDumpSpaces(ctxt);
if (attr == NULL) {
if (!ctxt->check)
fprintf(ctxt->output, "Attribute declaration is NULL\n");
return;
}
if (attr->type != XML_ATTRIBUTE_DECL) {
xmlDebugErr(ctxt, XML_CHECK_NOT_ATTR_DECL,
"Node is not an attribute declaration");
return;
}
if (attr->name != NULL) {
if (!ctxt->check)
fprintf(ctxt->output, "ATTRDECL(%s)", (char *) attr->name);
} else
xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
"Node attribute declaration has no name");
if (attr->elem != NULL) {
if (!ctxt->check)
fprintf(ctxt->output, " for %s", (char *) attr->elem);
} else
xmlDebugErr(ctxt, XML_CHECK_NO_ELEM,
"Node attribute declaration has no element name");
if (!ctxt->check) {
switch (attr->atype) {
case XML_ATTRIBUTE_CDATA:
fprintf(ctxt->output, " CDATA");
break;
case XML_ATTRIBUTE_ID:
fprintf(ctxt->output, " ID");
break;
case XML_ATTRIBUTE_IDREF:
fprintf(ctxt->output, " IDREF");
break;
case XML_ATTRIBUTE_IDREFS:
fprintf(ctxt->output, " IDREFS");
break;
case XML_ATTRIBUTE_ENTITY:
fprintf(ctxt->output, " ENTITY");
break;
case XML_ATTRIBUTE_ENTITIES:
fprintf(ctxt->output, " ENTITIES");
break;
case XML_ATTRIBUTE_NMTOKEN:
fprintf(ctxt->output, " NMTOKEN");
break;
case XML_ATTRIBUTE_NMTOKENS:
fprintf(ctxt->output, " NMTOKENS");
break;
case XML_ATTRIBUTE_ENUMERATION:
fprintf(ctxt->output, " ENUMERATION");
break;
case XML_ATTRIBUTE_NOTATION:
fprintf(ctxt->output, " NOTATION ");
break;
}
if (attr->tree != NULL) {
int indx;
xmlEnumerationPtr cur = attr->tree;
for (indx = 0; indx < 5; indx++) {
if (indx != 0)
fprintf(ctxt->output, "|%s", (char *) cur->name);
else
fprintf(ctxt->output, " (%s", (char *) cur->name);
cur = cur->next;
if (cur == NULL)
break;
}
if (cur == NULL)
fprintf(ctxt->output, ")");
else
fprintf(ctxt->output, "...)");
}
switch (attr->def) {
case XML_ATTRIBUTE_NONE:
break;
case XML_ATTRIBUTE_REQUIRED:
fprintf(ctxt->output, " REQUIRED");
break;
case XML_ATTRIBUTE_IMPLIED:
fprintf(ctxt->output, " IMPLIED");
break;
case XML_ATTRIBUTE_FIXED:
fprintf(ctxt->output, " FIXED");
break;
}
if (attr->defaultValue != NULL) {
fprintf(ctxt->output, "\"");
xmlCtxtDumpString(ctxt, attr->defaultValue);
fprintf(ctxt->output, "\"");
}
fprintf(ctxt->output, "\n");
}
/*
* Do a bit of checking
*/
xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) attr);
}
static void
xmlCtxtDumpElemDecl(xmlDebugCtxtPtr ctxt, xmlElementPtr elem)
{
xmlCtxtDumpSpaces(ctxt);
if (elem == NULL) {
if (!ctxt->check)
fprintf(ctxt->output, "Element declaration is NULL\n");
return;
}
if (elem->type != XML_ELEMENT_DECL) {
xmlDebugErr(ctxt, XML_CHECK_NOT_ELEM_DECL,
"Node is not an element declaration");
return;
}
if (elem->name != NULL) {
if (!ctxt->check) {
fprintf(ctxt->output, "ELEMDECL(");
xmlCtxtDumpString(ctxt, elem->name);
fprintf(ctxt->output, ")");
}
} else
xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
"Element declaration has no name");
if (!ctxt->check) {
switch (elem->etype) {
case XML_ELEMENT_TYPE_UNDEFINED:
fprintf(ctxt->output, ", UNDEFINED");
break;
case XML_ELEMENT_TYPE_EMPTY:
fprintf(ctxt->output, ", EMPTY");
break;
case XML_ELEMENT_TYPE_ANY:
fprintf(ctxt->output, ", ANY");
break;
case XML_ELEMENT_TYPE_MIXED:
fprintf(ctxt->output, ", MIXED ");
break;
case XML_ELEMENT_TYPE_ELEMENT:
fprintf(ctxt->output, ", MIXED ");
break;
}
if ((elem->type != XML_ELEMENT_NODE) && (elem->content != NULL)) {
char buf[5001];
buf[0] = 0;
xmlSnprintfElementContent(buf, 5000, elem->content, 1);
buf[5000] = 0;
fprintf(ctxt->output, "%s", buf);
}
fprintf(ctxt->output, "\n");
}
/*
* Do a bit of checking
*/
xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) elem);
}
static void
xmlCtxtDumpEntityDecl(xmlDebugCtxtPtr ctxt, xmlEntityPtr ent)
{
xmlCtxtDumpSpaces(ctxt);
if (ent == NULL) {
if (!ctxt->check)
fprintf(ctxt->output, "Entity declaration is NULL\n");
return;
}
if (ent->type != XML_ENTITY_DECL) {
xmlDebugErr(ctxt, XML_CHECK_NOT_ENTITY_DECL,
"Node is not an entity declaration");
return;
}
if (ent->name != NULL) {
if (!ctxt->check) {
fprintf(ctxt->output, "ENTITYDECL(");
xmlCtxtDumpString(ctxt, ent->name);
fprintf(ctxt->output, ")");
}
} else
xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
"Entity declaration has no name");
if (!ctxt->check) {
switch (ent->etype) {
case XML_INTERNAL_GENERAL_ENTITY:
fprintf(ctxt->output, ", internal\n");
break;
case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
fprintf(ctxt->output, ", external parsed\n");
break;
case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
fprintf(ctxt->output, ", unparsed\n");
break;
case XML_INTERNAL_PARAMETER_ENTITY:
fprintf(ctxt->output, ", parameter\n");
break;
case XML_EXTERNAL_PARAMETER_ENTITY:
fprintf(ctxt->output, ", external parameter\n");
break;
case XML_INTERNAL_PREDEFINED_ENTITY:
fprintf(ctxt->output, ", predefined\n");
break;
}
if (ent->ExternalID) {
xmlCtxtDumpSpaces(ctxt);
fprintf(ctxt->output, " ExternalID=%s\n",
(char *) ent->ExternalID);
}
if (ent->SystemID) {
xmlCtxtDumpSpaces(ctxt);
fprintf(ctxt->output, " SystemID=%s\n",
(char *) ent->SystemID);
}
if (ent->URI != NULL) {
xmlCtxtDumpSpaces(ctxt);
fprintf(ctxt->output, " URI=%s\n", (char *) ent->URI);
}
if (ent->content) {
xmlCtxtDumpSpaces(ctxt);
fprintf(ctxt->output, " content=");
xmlCtxtDumpString(ctxt, ent->content);
fprintf(ctxt->output, "\n");
}
}
/*
* Do a bit of checking
*/
xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) ent);
}
static void
xmlCtxtDumpNamespace(xmlDebugCtxtPtr ctxt, xmlNsPtr ns)
{
xmlCtxtDumpSpaces(ctxt);
if (ns == NULL) {
if (!ctxt->check)
fprintf(ctxt->output, "namespace node is NULL\n");
return;
}
if (ns->type != XML_NAMESPACE_DECL) {
xmlDebugErr(ctxt, XML_CHECK_NOT_NS_DECL,
"Node is not a namespace declaration");
return;
}
if (ns->href == NULL) {
if (ns->prefix != NULL)
xmlDebugErr3(ctxt, XML_CHECK_NO_HREF,
"Incomplete namespace %s href=NULL\n",
(char *) ns->prefix);
else
xmlDebugErr(ctxt, XML_CHECK_NO_HREF,
"Incomplete default namespace href=NULL\n");
} else {
if (!ctxt->check) {
if (ns->prefix != NULL)
fprintf(ctxt->output, "namespace %s href=",
(char *) ns->prefix);
else
fprintf(ctxt->output, "default namespace href=");
xmlCtxtDumpString(ctxt, ns->href);
fprintf(ctxt->output, "\n");
}
}
}
static void
xmlCtxtDumpNamespaceList(xmlDebugCtxtPtr ctxt, xmlNsPtr ns)
{
while (ns != NULL) {
xmlCtxtDumpNamespace(ctxt, ns);
ns = ns->next;
}
}
static void
xmlCtxtDumpEntity(xmlDebugCtxtPtr ctxt, xmlEntityPtr ent)
{
xmlCtxtDumpSpaces(ctxt);
if (ent == NULL) {
if (!ctxt->check)
fprintf(ctxt->output, "Entity is NULL\n");
return;
}
if (!ctxt->check) {
switch (ent->etype) {
case XML_INTERNAL_GENERAL_ENTITY:
fprintf(ctxt->output, "INTERNAL_GENERAL_ENTITY ");
break;
case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
fprintf(ctxt->output, "EXTERNAL_GENERAL_PARSED_ENTITY ");
break;
case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
fprintf(ctxt->output, "EXTERNAL_GENERAL_UNPARSED_ENTITY ");
break;
case XML_INTERNAL_PARAMETER_ENTITY:
fprintf(ctxt->output, "INTERNAL_PARAMETER_ENTITY ");
break;
case XML_EXTERNAL_PARAMETER_ENTITY:
fprintf(ctxt->output, "EXTERNAL_PARAMETER_ENTITY ");
break;
default:
fprintf(ctxt->output, "ENTITY_%d ! ", (int) ent->etype);
}
fprintf(ctxt->output, "%s\n", ent->name);
if (ent->ExternalID) {
xmlCtxtDumpSpaces(ctxt);
fprintf(ctxt->output, "ExternalID=%s\n",
(char *) ent->ExternalID);
}
if (ent->SystemID) {
xmlCtxtDumpSpaces(ctxt);
fprintf(ctxt->output, "SystemID=%s\n", (char *) ent->SystemID);
}
if (ent->URI) {
xmlCtxtDumpSpaces(ctxt);
fprintf(ctxt->output, "URI=%s\n", (char *) ent->URI);
}
if (ent->content) {
xmlCtxtDumpSpaces(ctxt);
fprintf(ctxt->output, "content=");
xmlCtxtDumpString(ctxt, ent->content);
fprintf(ctxt->output, "\n");
}
}
}
/**
* xmlCtxtDumpAttr:
* @output: the FILE * for the output
* @attr: the attribute
* @depth: the indentation level.
*
* Dumps debug information for the attribute
*/
static void
xmlCtxtDumpAttr(xmlDebugCtxtPtr ctxt, xmlAttrPtr attr)
{
xmlCtxtDumpSpaces(ctxt);
if (attr == NULL) {
if (!ctxt->check)
fprintf(ctxt->output, "Attr is NULL");
return;
}
if (!ctxt->check) {
fprintf(ctxt->output, "ATTRIBUTE ");
xmlCtxtDumpString(ctxt, attr->name);
fprintf(ctxt->output, "\n");
if (attr->children != NULL) {
ctxt->depth++;
xmlCtxtDumpNodeList(ctxt, attr->children);
ctxt->depth--;
}
}
if (attr->name == NULL)
xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
"Attribute has no name");
/*
* Do a bit of checking
*/
xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) attr);
}
/**
* xmlCtxtDumpAttrList:
* @output: the FILE * for the output
* @attr: the attribute list
* @depth: the indentation level.
*
* Dumps debug information for the attribute list
*/
static void
xmlCtxtDumpAttrList(xmlDebugCtxtPtr ctxt, xmlAttrPtr attr)
{
while (attr != NULL) {
xmlCtxtDumpAttr(ctxt, attr);
attr = attr->next;
}
}
/**
* xmlCtxtDumpOneNode:
* @output: the FILE * for the output
* @node: the node
* @depth: the indentation level.
*
* Dumps debug information for the element node, it is not recursive
*/
static void
xmlCtxtDumpOneNode(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
{
if (node == NULL) {
if (!ctxt->check) {
xmlCtxtDumpSpaces(ctxt);
fprintf(ctxt->output, "node is NULL\n");
}
return;
}
ctxt->node = node;
switch (node->type) {
case XML_ELEMENT_NODE:
if (!ctxt->check) {
xmlCtxtDumpSpaces(ctxt);
fprintf(ctxt->output, "ELEMENT ");
if ((node->ns != NULL) && (node->ns->prefix != NULL)) {
xmlCtxtDumpString(ctxt, node->ns->prefix);
fprintf(ctxt->output, ":");
}
xmlCtxtDumpString(ctxt, node->name);
fprintf(ctxt->output, "\n");
}
break;
case XML_ATTRIBUTE_NODE:
if (!ctxt->check)
xmlCtxtDumpSpaces(ctxt);
fprintf(ctxt->output, "Error, ATTRIBUTE found here\n");
xmlCtxtGenericNodeCheck(ctxt, node);
return;
case XML_TEXT_NODE:
if (!ctxt->check) {
xmlCtxtDumpSpaces(ctxt);
if (node->name == (const xmlChar *) xmlStringTextNoenc)
fprintf(ctxt->output, "TEXT no enc\n");
else
fprintf(ctxt->output, "TEXT\n");
}
break;
case XML_CDATA_SECTION_NODE:
if (!ctxt->check) {
xmlCtxtDumpSpaces(ctxt);
fprintf(ctxt->output, "CDATA_SECTION\n");
}
break;
case XML_ENTITY_REF_NODE:
if (!ctxt->check) {
xmlCtxtDumpSpaces(ctxt);
fprintf(ctxt->output, "ENTITY_REF(%s)\n",
(char *) node->name);
}
break;
case XML_ENTITY_NODE:
if (!ctxt->check) {
xmlCtxtDumpSpaces(ctxt);
fprintf(ctxt->output, "ENTITY\n");
}
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -