Home | History | Annotate | Download | only in libxml2

Lines Matching refs:ctxt

54 static void xmlCtxtDumpNodeList(xmlDebugCtxtPtr ctxt, xmlNodePtr node);
57 xmlCtxtDumpInitCtxt(xmlDebugCtxtPtr ctxt)
61 ctxt->depth = 0;
62 ctxt->check = 0;
63 ctxt->errors = 0;
64 ctxt->output = stdout;
65 ctxt->doc = NULL;
66 ctxt->node = NULL;
67 ctxt->dict = NULL;
68 ctxt->nodict = 0;
69 ctxt->options = 0;
71 ctxt->shift[i] = ' ';
72 ctxt->shift[100] = 0;
76 xmlCtxtDumpCleanCtxt(xmlDebugCtxtPtr ctxt ATTRIBUTE_UNUSED)
138 xmlCtxtDumpSpaces(xmlDebugCtxtPtr ctxt)
140 if (ctxt->check)
142 if ((ctxt->output != NULL) && (ctxt->depth > 0)) {
143 if (ctxt->depth < 50)
144 fprintf(ctxt->output, "%s", &ctxt->shift[100 - 2 * ctxt->depth]);
146 fprintf(ctxt->output, "%s", ctxt->shift);
152 * @ctxt: a debug context
158 xmlDebugErr(xmlDebugCtxtPtr ctxt, int error, const char *msg)
160 ctxt->errors++;
162 NULL, ctxt->node, XML_FROM_CHECK,
168 xmlDebugErr2(xmlDebugCtxtPtr ctxt, int error, const char *msg, int extra)
170 ctxt->errors++;
172 NULL, ctxt->node, XML_FROM_CHECK,
178 xmlDebugErr3(xmlDebugCtxtPtr ctxt, int error, const char *msg, const char *extra)
180 ctxt->errors++;
182 NULL, ctxt->node, XML_FROM_CHECK,
190 * @ctxt: the debugging context
197 xmlCtxtNsCheckScope(xmlDebugCtxtPtr ctxt, xmlNodePtr node, xmlNsPtr ns)
204 xmlDebugErr(ctxt, XML_CHECK_NS_SCOPE,
207 xmlDebugErr3(ctxt, XML_CHECK_NS_SCOPE,
213 xmlDebugErr(ctxt, XML_CHECK_NS_ANCESTOR,
216 xmlDebugErr3(ctxt, XML_CHECK_NS_ANCESTOR,
224 * @ctxt: the debug context
230 xmlCtxtCheckString(xmlDebugCtxtPtr ctxt, const xmlChar * str)
233 if (ctxt->check) {
235 xmlDebugErr3(ctxt, XML_CHECK_NOT_UTF8,
243 * @ctxt: the debug context
250 xmlCtxtCheckName(xmlDebugCtxtPtr ctxt, const xmlChar * name)
252 if (ctxt->check) {
254 xmlDebugErr(ctxt, XML_CHECK_NO_NAME, "Name is NULL");
259 xmlDebugErr3(ctxt, XML_CHECK_NOT_NCNAME,
263 if ((ctxt->dict != NULL) &&
264 (!xmlDictOwns(ctxt->dict, name)) &&
265 ((ctxt->doc == NULL) ||
266 ((ctxt->doc->parseFlags & (XML_PARSE_SAX1 | XML_PARSE_NODICT)) == 0))) {
267 xmlDebugErr3(ctxt, XML_CHECK_OUTSIDE_DICT,
275 xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) {
282 xmlDebugErr(ctxt, XML_CHECK_NO_PARENT,
285 xmlDebugErr(ctxt, XML_CHECK_NO_DOC,
290 if ((dict == NULL) && (ctxt->nodict == 0)) {
294 xmlDebugErr(ctxt, XML_CHECK_NO_DICT,
297 ctxt->nodict = 1;
299 if (ctxt->doc == NULL)
300 ctxt->doc = doc;
302 if (ctxt->dict == NULL) {
303 ctxt->dict = dict;
308 xmlDebugErr(ctxt, XML_CHECK_WRONG_DOC,
314 xmlDebugErr(ctxt, XML_CHECK_NO_PREV,
318 xmlDebugErr(ctxt, XML_CHECK_NO_PREV,
322 xmlDebugErr(ctxt, XML_CHECK_WRONG_PREV,
329 xmlDebugErr(ctxt, XML_CHECK_NO_NEXT,
333 xmlDebugErr(ctxt, XML_CHECK_WRONG_NEXT,
336 xmlDebugErr(ctxt, XML_CHECK_WRONG_PARENT,
344 xmlCtxtNsCheckScope(ctxt, node, ns);
348 xmlCtxtNsCheckScope(ctxt, node, node->ns);
351 xmlCtxtNsCheckScope(ctxt, node, node->ns);
362 xmlCtxtCheckString(ctxt, (const xmlChar *) node->content);
367 xmlCtxtCheckName(ctxt, node->name);
374 if ((ctxt->dict != NULL) &&
375 (node->name == xmlDictLookup(ctxt->dict, BAD_CAST "nbktext",
379 xmlDebugErr3(ctxt, XML_CHECK_WRONG_NAME,
386 xmlDebugErr3(ctxt, XML_CHECK_WRONG_NAME,
391 xmlCtxtCheckName(ctxt, node->name);
396 xmlDebugErr3(ctxt, XML_CHECK_NAME_NOT_NULL,
422 xmlCtxtDumpString(xmlDebugCtxtPtr ctxt, const xmlChar * str)
426 if (ctxt->check) {
431 fprintf(ctxt->output, "(NULL)");
438 fputc(' ', ctxt->output);
440 fprintf(ctxt->output, "#%X", str[i]);
442 fputc(str[i], ctxt->output);
443 fprintf(ctxt->output, "...");
447 xmlCtxtDumpDtdNode(xmlDebugCtxtPtr ctxt, xmlDtdPtr dtd)
449 xmlCtxtDumpSpaces(ctxt);
452 if (!ctxt->check)
453 fprintf(ctxt->output, "DTD node is NULL\n");
458 xmlDebugErr(ctxt, XML_CHECK_NOT_DTD,
462 if (!ctxt->check) {
464 fprintf(ctxt->output, "DTD(%s)", (char *) dtd->name);
466 fprintf(ctxt->output, "DTD");
468 fprintf(ctxt->output, ", PUBLIC %s", (char *) dtd->ExternalID);
470 fprintf(ctxt->output, ", SYSTEM %s", (char *) dtd->SystemID);
471 fprintf(ctxt->output, "\n");
476 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) dtd);
480 xmlCtxtDumpAttrDecl(xmlDebugCtxtPtr ctxt, xmlAttributePtr attr)
482 xmlCtxtDumpSpaces(ctxt);
485 if (!ctxt->check)
486 fprintf(ctxt->output, "Attribute declaration is NULL\n");
490 xmlDebugErr(ctxt, XML_CHECK_NOT_ATTR_DECL,
495 if (!ctxt->check)
496 fprintf(ctxt->output, "ATTRDECL(%s)", (char *) attr->name);
498 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
501 if (!ctxt->check)
502 fprintf(ctxt->output, " for %s", (char *) attr->elem);
504 xmlDebugErr(ctxt, XML_CHECK_NO_ELEM,
506 if (!ctxt->check) {
509 fprintf(ctxt->output, " CDATA");
512 fprintf(ctxt->output, " ID");
515 fprintf(ctxt->output, " IDREF");
518 fprintf(ctxt->output, " IDREFS");
521 fprintf(ctxt->output, " ENTITY");
524 fprintf(ctxt->output, " ENTITIES");
527 fprintf(ctxt->output, " NMTOKEN");
530 fprintf(ctxt->output, " NMTOKENS");
533 fprintf(ctxt->output, " ENUMERATION");
536 fprintf(ctxt->output, " NOTATION ");
545 fprintf(ctxt->output, "|%s", (char *) cur->name);
547 fprintf(ctxt->output, " (%s", (char *) cur->name);
553 fprintf(ctxt->output, ")");
555 fprintf(ctxt->output, "...)");
561 fprintf(ctxt->output, " REQUIRED");
564 fprintf(ctxt->output, " IMPLIED");
567 fprintf(ctxt->output, " FIXED");
571 ctxt->output, "\"");
572 xmlCtxtDumpString(ctxt, attr->defaultValue);
573 fprintf(ctxt->output, "\"");
575 fprintf(ctxt->output, "\n");
581 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) attr);
585 xmlCtxtDumpElemDecl(xmlDebugCtxtPtr ctxt, xmlElementPtr elem)
587 xmlCtxtDumpSpaces(ctxt);
590 if (!ctxt->check)
591 fprintf(ctxt->output, "Element declaration is NULL\n");
595 xmlDebugErr(ctxt, XML_CHECK_NOT_ELEM_DECL,
600 if (!ctxt->check) {
601 fprintf(ctxt->output, "ELEMDECL(");
602 xmlCtxtDumpString(ctxt, elem->name);
603 fprintf(ctxt->output, ")");
606 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
608 if (!ctxt->check) {
611 fprintf(ctxt->output, ", UNDEFINED");
614 fprintf(ctxt->output, ", EMPTY");
617 fprintf(ctxt->output, ", ANY");
620 fprintf(ctxt->output, ", MIXED ");
623 fprintf(ctxt->output, ", MIXED ");
632 fprintf(ctxt->output, "%s", buf);
634 fprintf(ctxt->output, "\n");
640 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) elem);
644 xmlCtxtDumpEntityDecl(xmlDebugCtxtPtr ctxt, xmlEntityPtr ent)
646 xmlCtxtDumpSpaces(ctxt);
649 if (!ctxt->check)
650 fprintf(ctxt->output, "Entity declaration is NULL\n");
654 xmlDebugErr(ctxt, XML_CHECK_NOT_ENTITY_DECL,
659 if (!ctxt->check) {
660 fprintf(ctxt->output, "ENTITYDECL(");
661 xmlCtxtDumpString(ctxt, ent->name);
662 fprintf(ctxt->output, ")");
665 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
667 if (!ctxt->check) {
670 fprintf(ctxt->output, ", internal\n");
673 fprintf(ctxt->output, ", external parsed\n");
676 fprintf(ctxt->output, ", unparsed\n");
679 fprintf(ctxt->output, ", parameter\n");
682 fprintf(ctxt->output, ", external parameter\n");
685 fprintf(ctxt->output, ", predefined\n");
689 xmlCtxtDumpSpaces(ctxt);
690 fprintf(ctxt->output, " ExternalID=%s\n",
694 xmlCtxtDumpSpaces(ctxt);
695 fprintf(ctxt->output, " SystemID=%s\n",
699 xmlCtxtDumpSpaces(ctxt);
700 fprintf(ctxt->output, " URI=%s\n", (char *) ent->URI);
703 xmlCtxtDumpSpaces(ctxt);
704 fprintf(ctxt->output, " content=");
705 xmlCtxtDumpString(ctxt, ent->content);
706 fprintf(ctxt->output, "\n");
713 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) ent);
717 xmlCtxtDumpNamespace(xmlDebugCtxtPtr ctxt, xmlNsPtr ns)
719 xmlCtxtDumpSpaces(ctxt);
722 if (!ctxt->check)
723 fprintf(ctxt->output, "namespace node is NULL\n");
727 xmlDebugErr(ctxt, XML_CHECK_NOT_NS_DECL,
733 xmlDebugErr3(ctxt, XML_CHECK_NO_HREF,
737 xmlDebugErr(ctxt, XML_CHECK_NO_HREF,
740 if (!ctxt->check) {
742 fprintf(ctxt->output, "namespace %s href=",
745 fprintf(ctxt->output, "default namespace href=");
747 xmlCtxtDumpString(ctxt, ns->href);
748 fprintf(ctxt->output, "\n");
754 xmlCtxtDumpNamespaceList(xmlDebugCtxtPtr ctxt, xmlNsPtr ns)
757 xmlCtxtDumpNamespace(ctxt, ns);
763 xmlCtxtDumpEntity(xmlDebugCtxtPtr ctxt, xmlEntityPtr ent)
765 xmlCtxtDumpSpaces(ctxt);
768 if (!ctxt->check)
769 fprintf(ctxt->output, "Entity is NULL\n");
772 if (!ctxt->check) {
775 fprintf(ctxt->output, "INTERNAL_GENERAL_ENTITY ");
778 fprintf(ctxt->output, "EXTERNAL_GENERAL_PARSED_ENTITY ");
781 fprintf(ctxt->output, "EXTERNAL_GENERAL_UNPARSED_ENTITY ");
784 fprintf(ctxt->output, "INTERNAL_PARAMETER_ENTITY ");
787 fprintf(ctxt->output, "EXTERNAL_PARAMETER_ENTITY ");
790 fprintf(ctxt->output, "ENTITY_%d ! ", (int) ent->etype);
792 fprintf(ctxt->output, "%s\n", ent->name);
794 xmlCtxtDumpSpaces(ctxt);
795 fprintf(ctxt->output, "ExternalID=%s\n",
799 xmlCtxtDumpSpaces(ctxt);
800 fprintf(ctxt->output, "SystemID=%s\n", (char *) ent->SystemID);
803 xmlCtxtDumpSpaces(ctxt);
804 fprintf(ctxt->output, "URI=%s\n", (char *) ent->URI);
807 xmlCtxtDumpSpaces(ctxt);
808 fprintf(ctxt->output, "content=");
809 xmlCtxtDumpString(ctxt, ent->content);
810 fprintf(ctxt->output, "\n");
824 xmlCtxtDumpAttr(xmlDebugCtxtPtr ctxt, xmlAttrPtr attr)
826 xmlCtxtDumpSpaces(ctxt);
829 if (!ctxt->check)
830 fprintf(ctxt->output, "Attr is NULL");
833 if (!ctxt->check) {
834 fprintf(ctxt->output, "ATTRIBUTE ");
835 xmlCtxtDumpString(ctxt, attr->name);
836 fprintf(ctxt->output, "\n");
838 ctxt->depth++;
839 xmlCtxtDumpNodeList(ctxt, attr->children);
840 ctxt->depth--;
844 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
850 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) attr);
862 xmlCtxtDumpAttrList(xmlDebugCtxtPtr ctxt, xmlAttrPtr attr)
865 xmlCtxtDumpAttr(ctxt, attr);
879 xmlCtxtDumpOneNode(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
882 if (!ctxt->check) {
883 xmlCtxtDumpSpaces(ctxt);
884 fprintf(ctxt->output, "node is NULL\n");
888 ctxt->node = node;
892 if (!ctxt->check) {
893 xmlCtxtDumpSpaces(ctxt);
894 fprintf(ctxt->output, "ELEMENT ");
896 xmlCtxtDumpString(ctxt, node->ns->prefix);
897 fprintf(ctxt->output, ":");
899 xmlCtxtDumpString(ctxt, node->name);
900 fprintf(ctxt->output, "\n");
904 if (!ctxt->check)
905 xmlCtxtDumpSpaces(ctxt);
906 fprintf(ctxt->output, "Error, ATTRIBUTE found here\n");
907 xmlCtxtGenericNodeCheck(ctxt, node);
910 if (!ctxt->check) {
911 xmlCtxtDumpSpaces(ctxt);
913 fprintf(ctxt->output, "TEXT no enc");
915 fprintf(ctxt->output, "TEXT");
916 if (ctxt->options & DUMP_TEXT_TYPE) {
918 fprintf(ctxt->output, " compact\n");
919 else if (xmlDictOwns(ctxt->dict, node->content) == 1)
920 fprintf(ctxt->output, " interned\n");
922 fprintf(ctxt->output, "\n");
924 fprintf(ctxt->output, "\n");
928 if (!ctxt->check) {
929 xmlCtxtDumpSpaces(ctxt);
930 fprintf(ctxt->output, "CDATA_SECTION\n");
934 if (!ctxt->check) {
935 xmlCtxtDumpSpaces(ctxt);
936 fprintf(ctxt->output, "ENTITY_REF(%s)\n",
941 if (!ctxt->check) {
942 xmlCtxtDumpSpaces(ctxt);
943 fprintf(ctxt->output, "ENTITY\n");
947 if (!ctxt->check) {
948 xmlCtxtDumpSpaces(ctxt);
949 fprintf(ctxt->output, "PI %s\n", (char *) node->name);
953 if (!ctxt->check) {
954 xmlCtxtDumpSpaces(ctxt);
955 fprintf(ctxt->output, "COMMENT\n");
960 if (!ctxt->check) {
961 xmlCtxtDumpSpaces(ctxt);
963 fprintf(ctxt->output, "Error, DOCUMENT found here\n");
964 xmlCtxtGenericNodeCheck(ctxt, node);
967 if (!ctxt->check) {
968 xmlCtxtDumpSpaces(ctxt);
969 fprintf(ctxt->output, "DOCUMENT_TYPE\n");
973 if (!ctxt->check) {
974 xmlCtxtDumpSpaces(ctxt);
975 fprintf(ctxt->output, "DOCUMENT_FRAG\n");
979 if (!ctxt->check) {
980 xmlCtxtDumpSpaces(ctxt);
981 fprintf(ctxt->output, "NOTATION\n");
985 xmlCtxtDumpDtdNode(ctxt, (xmlDtdPtr) node);
988 xmlCtxtDumpElemDecl(ctxt, (xmlElementPtr) node);
991 xmlCtxtDumpAttrDecl(ctxt, (xmlAttributePtr) node);
994 xmlCtxtDumpEntityDecl(ctxt, (xmlEntityPtr) node);
997 xmlCtxtDumpNamespace(ctxt, (xmlNsPtr) node);
1000 if (!ctxt->check) {
1001 xmlCtxtDumpSpaces(ctxt);
1002 fprintf(ctxt->output, "INCLUDE START\n");
1006 if (!ctxt->check) {
1007 xmlCtxtDumpSpaces(ctxt);
1008 fprintf(ctxt->output, "INCLUDE END\n");
1012 if (!ctxt->check)
1013 xmlCtxtDumpSpaces(ctxt);
1014 xmlDebugErr2(ctxt, XML_CHECK_UNKNOWN_NODE,
1019 if (!ctxt->check) {
1020 xmlCtxtDumpSpaces(ctxt);
1022 fprintf(ctxt->output, "PBM: doc == NULL !!!\n");
1024 ctxt->depth++;
1026 xmlCtxtDumpNamespaceList(ctxt, node->nsDef);
1028 xmlCtxtDumpAttrList(ctxt, node->properties);
1031 if (!ctxt->check) {
1032 xmlCtxtDumpSpaces(ctxt);
1033 fprintf(ctxt->output, "content=");
1034 xmlCtxtDumpString(ctxt, node->content);
1035 fprintf(ctxt->output, "\n");
1043 xmlCtxtDumpEntity(ctxt, ent);
1045 ctxt->depth--;
1050 xmlCtxtGenericNodeCheck(ctxt, node);
1062 xmlCtxtDumpNode(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
1065 if (!ctxt->check) {
1066 xmlCtxtDumpSpaces(ctxt);
1067 fprintf(ctxt->output, "node is NULL\n");
1071 xmlCtxtDumpOneNode(ctxt, node);
1074 ctxt->depth++;
1075 xmlCtxtDumpNodeList(ctxt, node->children);
1076 ctxt->depth--;
1089 xmlCtxtDumpNodeList(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
1092 xmlCtxtDumpNode(ctxt, node);
1098 xmlCtxtDumpDocHead(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1101 if (!ctxt->check)
1102 fprintf(ctxt->output, "DOCUMENT == NULL !\n");
1105 ctxt->node = (xmlNodePtr) doc;
1109 xmlDebugErr(ctxt, XML_CHECK_FOUND_ELEMENT,
1113 xmlDebugErr(ctxt
1117 xmlDebugErr(ctxt, XML_CHECK_FOUND_TEXT,
1121 xmlDebugErr(ctxt, XML_CHECK_FOUND_CDATA,
1125 xmlDebugErr(ctxt, XML_CHECK_FOUND_ENTITYREF,
1129 xmlDebugErr(ctxt, XML_CHECK_FOUND_ENTITY,
1133 xmlDebugErr(ctxt, XML_CHECK_FOUND_PI,
1137 xmlDebugErr(ctxt, XML_CHECK_FOUND_COMMENT,
1141 if (!ctxt->check)
1142 fprintf(ctxt->output, "DOCUMENT\n");
1145 if (!ctxt->check)
1146 fprintf(ctxt->output, "HTML DOCUMENT\n");
1149 xmlDebugErr(ctxt, XML_CHECK_FOUND_DOCTYPE,
1153 xmlDebugErr(ctxt, XML_CHECK_FOUND_FRAGMENT,
1157 xmlDebugErr(ctxt, XML_CHECK_FOUND_NOTATION,
1161 xmlDebugErr2(ctxt, XML_CHECK_UNKNOWN_NODE,
1174 xmlCtxtDumpDocumentHead(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1177 xmlCtxtDumpDocHead(ctxt, doc);
1178 if (!ctxt->check) {
1180 fprintf(ctxt->output, "name=");
1181 xmlCtxtDumpString(ctxt, BAD_CAST doc->name);
1182 fprintf(ctxt->output, "\n");
1185 fprintf(ctxt->output, "version=");
1186 xmlCtxtDumpString(ctxt, doc->version);
1187 fprintf(ctxt->output, "\n");
1190 fprintf(ctxt->output, "encoding=");
1191 xmlCtxtDumpString(ctxt, doc->encoding);
1192 fprintf(ctxt->output, "\n");
1195 fprintf(ctxt->output, "URL=");
1196 xmlCtxtDumpString(ctxt, doc->URL);
1197 fprintf(ctxt->output, "\n");
1200 fprintf(ctxt->output, "standalone=true\n");
1203 xmlCtxtDumpNamespaceList(ctxt, doc->oldNs);
1214 xmlCtxtDumpDocument(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1217 if (!ctxt->check)
1218 fprintf(ctxt->output, "DOCUMENT == NULL !\n");
1221 xmlCtxtDumpDocumentHead(ctxt, doc);
1225 ctxt->depth++;
1226 xmlCtxtDumpNodeList(ctxt, doc->children);
1227 ctxt->depth--;
1236 xmlDebugCtxtPtr ctxt = (xmlDebugCtxtPtr) data;
1238 if (!ctxt->check)
1239 fprintf(ctxt->output, "Entity is NULL");
1242 if (!ctxt->check) {
1243 fprintf(ctxt->output, "%s : ", (char *) cur->name);
1246 fprintf(ctxt->output, "INTERNAL GENERAL, ");
1249 fprintf(ctxt->output, "EXTERNAL PARSED, ");
1252 fprintf(ctxt->output, "EXTERNAL UNPARSED, ");
1255 fprintf(ctxt->output, "INTERNAL PARAMETER, ");
1258 fprintf(ctxt->output, "EXTERNAL PARAMETER, ");
1261 xmlDebugErr2(ctxt, XML_CHECK_ENTITY_TYPE,
1265 fprintf(ctxt->output, "ID \"%s\"", (char *) cur->ExternalID);
1267 fprintf(ctxt->output, "SYSTEM \"%s\"", (char *) cur->SystemID);
1269 fprintf(ctxt->output, "\n orig \"%s\"", (char *) cur->orig);
1271 fprintf(ctxt->output, "\n content \"%s\"",
1273 fprintf(ctxt->output, "\n");
1285 xmlCtxtDumpEntities(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1288 xmlCtxtDumpDocHead(ctxt, doc);
1293 if (!ctxt->check)
1294 fprintf(ctxt->output, "Entities in internal subset\n");
1295 xmlHashScan(table, xmlCtxtDumpEntityCallback, ctxt);
1297 fprintf(ctxt->output, "No entities in internal subset\n");
1302 if (!ctxt->check)
1303 fprintf(ctxt->output, "Entities in external subset\n");
1304 xmlHashScan(table, xmlCtxtDumpEntityCallback, ctxt);
1305 } else if (!ctxt->check)
1306 fprintf(ctxt->output, "No entities in external subset\n");
1317 xmlCtxtDumpDTD(xmlDebugCtxtPtr ctxt, xmlDtdPtr dtd)
1320 if (!ctxt->check)
1321 fprintf(ctxt->output, "DTD is NULL\n");
1324 xmlCtxtDumpDtdNode(ctxt, dtd);
1326 fprintf(ctxt->output, " DTD is empty\n");
1328 ctxt->depth++;
1329 xmlCtxtDumpNodeList(ctxt, dtd->children);
1330 ctxt->depth--;
1380 xmlDebugCtxt ctxt;
1383 xmlCtxtDumpInitCtxt(&ctxt);
1384 ctxt.output = output;
1385 ctxt.depth = depth;
1386 xmlCtxtDumpAttr(&ctxt, attr);
1387 xmlCtxtDumpCleanCtxt(&ctxt);
1401 xmlDebugCtxt ctxt;
1404 xmlCtxtDumpInitCtxt(&ctxt);
1405 ctxt.output = output;
1406 xmlCtxtDumpEntities(&ctxt, doc);
1407 xmlCtxtDumpCleanCtxt(&ctxt);
1421 xmlDebugCtxt ctxt;
1424 xmlCtxtDumpInitCtxt(&ctxt);
1425 ctxt.output = output;
1426 ctxt.depth = depth;
1427 xmlCtxtDumpAttrList(&ctxt, attr);
1428 xmlCtxtDumpCleanCtxt(&ctxt);
1442 xmlDebugCtxt ctxt;
1445 xmlCtxtDumpInitCtxt(&ctxt);
1446 ctxt.output = output;
1447 ctxt.depth = depth;
1448 xmlCtxtDumpOneNode(&ctxt, node);
1449 xmlCtxtDumpCleanCtxt(&ctxt);
1463 xmlDebugCtxt ctxt;
1467 xmlCtxtDumpInitCtxt(&ctxt);
1468 ctxt.output = output;
1469 ctxt.depth = depth;
1470 xmlCtxtDumpNode(&ctxt, node);
1471 xmlCtxtDumpCleanCtxt(&ctxt);
1485 xmlDebugCtxt ctxt;
1489 xmlCtxtDumpInitCtxt(&ctxt);
1490 ctxt.output = output;
1491 ctxt.depth = depth;
1492 xmlCtxtDumpNodeList(&ctxt, node);
1493 xmlCtxtDumpCleanCtxt(&ctxt);
1506 xmlDebugCtxt ctxt;
1510 xmlCtxtDumpInitCtxt(&ctxt);
1511 ctxt.options |= DUMP_TEXT_TYPE;
1512 ctxt.output = output;
1513 xmlCtxtDumpDocumentHead(&ctxt, doc);
1514 xmlCtxtDumpCleanCtxt(&ctxt);
1527 xmlDebugCtxt ctxt;
1531 xmlCtxtDumpInitCtxt(&ctxt);
1532 ctxt.options |= DUMP_TEXT_TYPE;
1533 ctxt.output = output;
1534 xmlCtxtDumpDocument(&ctxt, doc);
1535 xmlCtxtDumpCleanCtxt(&ctxt);
1548 xmlDebugCtxt ctxt;
1552 xmlCtxtDumpInitCtxt(&ctxt);
1553 ctxt.options |= DUMP_TEXT_TYPE;
1554 ctxt.output = output;
1555 xmlCtxtDumpDTD(&ctxt, dtd);
1556 xmlCtxtDumpCleanCtxt(&ctxt);
1578 xmlDebugCtxt ctxt;
1582 xmlCtxtDumpInitCtxt(&ctxt);
1583 ctxt.output = output;
1584 ctxt.check = 1;
1585 xmlCtxtDumpDocument(&ctxt, doc);
1586 xmlCtxtDumpCleanCtxt(&ctxt);
1587 return(ctxt.errors);
1885 * @ctxt : a non-null shell context
1891 xmlShellPrintNodeCtxt(xmlShellCtxtPtr ctxt,xmlNodePtr node)
1897 if (ctxt == NULL)
1900 fp = ctxt->output;
1927 * @ctxt: a valid shell context
1933 xmlShellPrintXPathResultCtxt(xmlShellCtxtPtr ctxt,xmlXPathObjectPtr list)
1935 if (!ctxt)
1947 xmlShellPrintNodeCtxt(ctxt,
1994 * @ctxt: the shell context
2005 xmlShellList(xmlShellCtxtPtr ctxt,
2010 if (!ctxt)
2013 fprintf(ctxt->output, "NULL\n");
2020 xmlLsOneNode(ctxt->output, node);
2025 xmlLsOneNode(ctxt->output, node);
2029 xmlLsOneNode(ctxt->output, cur);
2037 * @ctxt: the shell context
2048 xmlShellBase(xmlShellCtxtPtr ctxt,
2053 if (!ctxt)
2056 fprintf(ctxt->output, "NULL\n");
2063 fprintf(ctxt->output, " No base found !!!\n");
2065 fprintf(ctxt->output, "%s\n", base);
2074 * @ctxt: the shell context
2085 xmlShellSetBase(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2097 * @ctxt: the shell context
2109 xmlShellRegisterNamespace(xmlShellCtxtPtr ctxt, char *arg,
2128 fprintf(ctxt->output, "setns: prefix=[nsuri] required\n");
2142 if(xmlXPathRegisterNs(ctxt->pctxt, prefix, href) != 0) {
2143 fprintf(ctxt->output,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", prefix, href);
2154 * @ctxt: the shell context
2165 xmlShellRegisterRootNamespaces(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_UNUSED,
2171 (root->nsDef == NULL) || (ctxt == NULL) || (ctxt->pctxt == NULL))
2176 xmlXPathRegisterNs(ctxt->pctxt, BAD_CAST "defaultns", ns->href);
2178 xmlXPathRegisterNs(ctxt->pctxt, ns->prefix, ns->href);
2187 * @ctxt: the shell context
2198 xmlShellGrep(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2201 if (!ctxt)
2218 fprintf(ctxt->output, "%s : ", xmlGetNodePath(node));
2219 xmlShellList(ctxt, NULL, node, NULL);
2224 fprintf(ctxt->output, "%s : ", xmlGetNodePath(node->parent));
2225 xmlShellList(ctxt, NULL, node->parent, NULL);
2265 * @ctxt: the shell context
2276 xmlShellDir(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2280 if (!ctxt)
2283 fprintf(ctxt->output, "NULL\n");
2288 xmlDebugDumpDocumentHead(ctxt->output, (xmlDocPtr) node);
2290 xmlDebugDumpAttr(ctxt->output, (xmlAttrPtr) node, 0);
2292 xmlDebugDumpOneNode(ctxt->output, node, 0);
2299 * @ctxt: the shell context
2310 xmlShellSetContent(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2317 if (!ctxt)
2320 fprintf(ctxt->output, "NULL\n");
2324 fprintf(ctxt->output, "NULL\n");
2337 fprintf(ctxt->output, "failed to parse content\n");
2345 * @ctxt: the shell context
2361 xmlRelaxNGParserCtxtPtr ctxt;
2365 ctxt = xmlRelaxNGNewParserCtxt(schemas);
2366 xmlRelaxNGSetParserErrors(ctxt,
2370 relaxngschemas = xmlRelaxNGParse(ctxt);
2371 xmlRelaxNGFreeParserCtxt(ctxt);
2401 * @ctxt: the shell context
2412 xmlShellCat(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_UNUSED,
2415 if (!ctxt)
2418 fprintf(ctxt->output, "NULL\n");
2421 if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) {
2424 htmlDocDump(ctxt->output, (htmlDocPtr) node);
2426 htmlNodeDumpFile(ctxt->output, ctxt->doc, node);
2429 xmlDocDump(ctxt->output, (xmlDocPtr) node);
2431 xmlElemDump(ctxt->output, ctxt->doc, node);
2435 xmlDocDump(ctxt->output, (xmlDocPtr) node);
2437 xmlElemDump(ctxt->output, ctxt->doc, node);
2439 fprintf(ctxt->output, "\n");
2446 * @ctxt: the shell context
2457 xmlShellLoad(xmlShellCtxtPtr ctxt, char *filename,
2464 if ((ctxt == NULL) || (filename == NULL)) return(-1);
2465 if (ctxt->doc != NULL)
2466 html = (ctxt->doc->type == XML_HTML_DOCUMENT_NODE);
2472 fprintf(ctxt->output, "HTML support not compiled in\n");
2479 if (ctxt->loaded == 1) {
2480 xmlFreeDoc(ctxt->doc);
2482 ctxt->loaded = 1;
2484 xmlXPathFreeContext(ctxt->pctxt);
2486 xmlFree(ctxt->filename);
2487 ctxt->doc = doc;
2488 ctxt->node = (xmlNodePtr) doc;
2490 ctxt->pctxt = xmlXPathNewContext(doc);
2492 ctxt->filename = (char *) xmlCanonicPath((xmlChar *) filename);
2501 * @ctxt: the shell context
2513 xmlShellWrite(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
2530 if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
2538 if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
2544 if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
2560 xmlElemDump(f, ctxt->doc, node);
2569 * @ctxt: the shell context
2580 xmlShellSave(xmlShellCtxtPtr ctxt, char *filename,
2584 if ((ctxt == NULL) || (ctxt->doc == NULL))
2587 filename = ctxt->filename;
2597 switch (ctxt->doc->type) {
2599 if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
2606 if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
2611 if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
2630 * @ctxt: the shell context
2642 xmlShellValidate(xmlShellCtxtPtr ctxt, char *dtd,
2649 if ((ctxt == NULL) || (ctxt->doc == NULL)) return(-1);
2655 res = xmlValidateDocument(&vctxt, ctxt->doc);
2661 res = xmlValidateDtd(&vctxt, ctxt->doc, subset);
2672 * @ctxt: the shell context
2684 xmlShellDu(xmlShellCtxtPtr ctxt,
2691 if (!ctxt)
2700 fprintf(ctxt->output, "/\n");
2703 fprintf(ctxt->output, " ");
2705 fprintf(ctxt->output, "%s:", node->ns->prefix);
2706 fprintf(ctxt->output, "%s\n", node->name);
2756 * @ctxt: the shell context
2769 xmlShellPwd(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED, char *buffer,
2816 xmlShellCtxtPtr ctxt;
2827 ctxt = (xmlShellCtxtPtr) xmlMalloc(sizeof(xmlShellCtxt));
2828 if (ctxt == NULL)
2830 ctxt->loaded = 0;
2831 ctxt->doc = doc;
2832 ctxt->input = input;
2833 ctxt->output = output;
2834 ctxt->filename = (char *) xmlStrdup((xmlChar *) filename);
2835 ctxt->node = (xmlNodePtr) ctxt->doc;
2838 ctxt->pctxt = xmlXPathNewContext(ctxt->doc);
2839 if (ctxt->pctxt == NULL) {
2840 xmlFree(ctxt);
2845 if (ctxt->node == (xmlNodePtr) ctxt->doc)
2847 else if ((ctxt->node != NULL) && (ctxt->node->name) &&
2848 (ctxt->node->ns) && (ctxt->node->ns->prefix))
2850 (ctxt->node->ns->prefix), ctxt->node->name);
2851 else if ((ctxt->node != NULL) && (ctxt->node->name))
2852 snprintf(prompt, sizeof(prompt), "%s > ", ctxt->node->name);
2860 cmdline = ctxt->input(prompt);
2904 fprintf(ctxt->output, "\tbase display XML base of the node\n");
2905 fprintf(ctxt->output, "\tsetbase URI change the XML base of the node\n");
2906 fprintf(ctxt->output, "\tbye leave shell\n");
2907 fprintf(ctxt->output, "\tcat [node] display node or current node\n");
2908 fprintf(ctxt->output, "\tcd [path] change directory to path or to root\n");
2909 fprintf(ctxt->output, "\tdir [path] dumps informations about the node (namespace, attributes, content)\n");
2910 fprintf(ctxt->output, "\tdu [path] show the structure of the subtree under path or the current node\n");
2911 fprintf(ctxt->output, "\texit leave shell\n");
2912 fprintf(ctxt->output, "\thelp display this help\n");
2913 fprintf(ctxt->output, "\tfree display memory usage\n");
2914 fprintf(ctxt->output, "\tload [name] load a new document with name\n");
2915 fprintf(ctxt->output, "\tls [path] list contents of path or the current directory\n");
2916 fprintf(ctxt->output, "\tset xml_fragment replace the current node content with the fragment parsed in context\n");
2918 fprintf(ctxt->output, "\txpath expr evaluate the XPath expression in that context and print the result\n");
2919 fprintf(ctxt->output, "\tsetns nsreg register a namespace to a prefix in the XPath evaluation context\n");
2920 fprintf(ctxt->output, "\t format for nsreg is: prefix=[nsuri] (i.e. prefix= unsets a prefix)\n");
2921 fprintf(ctxt->output, "\tsetrootns register all namespace found on the root element\n");
2922 fprintf(ctxt
2924 fprintf(ctxt->output, "\tpwd display current working directory\n");
2925 fprintf(ctxt->output, "\twhereis display absolute path of [path] or current working directory\n");
2926 fprintf(ctxt->output, "\tquit leave shell\n");
2928 fprintf(ctxt->output, "\tsave [name] save this document to name or the original name\n");
2929 fprintf(ctxt->output, "\twrite [name] write the current node to the filename\n");
2932 fprintf(ctxt->output, "\tvalidate check the document for errors\n");
2935 fprintf(ctxt->output, "\trelaxng rng validate the document against the Relax-NG schemas\n");
2937 fprintf(ctxt->output, "\tgrep string search for a string in the subtree\n");
2940 xmlShellValidate(ctxt, arg, NULL, NULL);
2943 xmlShellLoad(ctxt, arg, NULL, NULL);
2946 xmlShellRNGValidate(ctxt, arg, NULL, NULL);
2950 xmlShellSave(ctxt, arg, NULL, NULL);
2956 xmlShellWrite(ctxt, arg, ctxt->node, NULL);
2959 xmlShellGrep(ctxt, arg, ctxt->node, NULL);
2962 xmlMemShow(ctxt->output, 0);
2967 xmlMemShow(ctxt->output, len);
2972 if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL))
2973 fprintf(ctxt->output, "%s\n", dir);
2976 xmlShellDu(ctxt, NULL, ctxt->node, NULL);
2978 ctxt->pctxt->node = ctxt->node;
2980 ctxt->pctxt->node = ctxt->node;
2981 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3000 xmlShellDu(ctxt, NULL,
3046 ctxt->pctxt->node = NULL;
3049 xmlShellBase(ctxt, NULL, ctxt->node, NULL);
3051 xmlShellSetContent(ctxt, arg, ctxt->node, NULL);
3058 xmlShellRegisterNamespace(ctxt, arg, NULL, NULL);
3063 root = xmlDocGetRootElement(ctxt->doc);
3064 xmlShellRegisterRootNamespaces(ctxt, NULL, root, NULL);
3070 ctxt->pctxt->node = ctxt->node;
3071 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3072 xmlXPathDebugDumpObject(ctxt->output, list, 0);
3078 xmlShellSetBase(ctxt, arg, ctxt->node, NULL);
3085 xmlShellDir(ctxt, NULL, ctxt->node, NULL);
3087 xmlShellList(ctxt, NULL, ctxt->node, NULL);
3089 ctxt->pctxt->node = ctxt->node;
3091 ctxt->pctxt->node = ctxt->node;
3092 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3112 xmlShellDir(ctxt, NULL,
3116 xmlShellList(ctxt, NULL,
3163 ctxt->pctxt->node = NULL;
3169 if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL))
3170 fprintf(ctxt->output, "%s\n", dir);
3172 ctxt->pctxt->node = ctxt->node;
3174 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3193 if (!xmlShellPwd(ctxt, dir, list->nodesetval->
3195 fprintf(ctxt->output, "%s\n", dir);
3240 ctxt->pctxt->node = NULL;
3244 ctxt->node = (xmlNodePtr) ctxt->doc;
3249 ctxt->pctxt->node = ctxt->node;
3253 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3266 ctxt->node = list->nodesetval->nodeTab[0];
3267 if ((ctxt->node != NULL) &&
3268 (ctxt->node->type ==
3272 ctxt->node = NULL;
3325 ctxt->pctxt->node = NULL;
3330 xmlShellCat(ctxt, NULL, ctxt->node, NULL);
3332 ctxt->pctxt->node = ctxt->node;
3334 ctxt->pctxt->node = ctxt->node;
3335 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3355 fprintf(ctxt->output, " -------\n");
3356 xmlShellCat(ctxt, NULL,
3403 ctxt->pctxt->node = NULL;
3414 xmlXPathFreeContext(ctxt->pctxt);
3416 if (ctxt->loaded) {
3417 xmlFreeDoc(ctxt->doc);
3419 if (ctxt->filename != NULL)
3420 xmlFree(ctxt->filename);
3421 xmlFree(ctxt);