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");
258 xmlDebugErr3(ctxt, XML_CHECK_NOT_NCNAME,
261 if ((ctxt->dict != NULL) &&
262 (!xmlDictOwns(ctxt->dict, name)) &&
263 ((ctxt->doc == NULL) ||
264 ((ctxt->doc->parseFlags & (XML_PARSE_SAX1 | XML_PARSE_NODICT)) == 0))) {
265 xmlDebugErr3(ctxt, XML_CHECK_OUTSIDE_DICT,
273 xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) {
280 xmlDebugErr(ctxt, XML_CHECK_NO_PARENT,
283 xmlDebugErr(ctxt, XML_CHECK_NO_DOC,
288 if ((dict == NULL) && (ctxt->nodict == 0)) {
292 xmlDebugErr(ctxt, XML_CHECK_NO_DICT,
295 ctxt->nodict = 1;
297 if (ctxt->doc == NULL)
298 ctxt->doc = doc;
300 if (ctxt->dict == NULL) {
301 ctxt->dict = dict;
306 xmlDebugErr(ctxt, XML_CHECK_WRONG_DOC,
312 xmlDebugErr(ctxt, XML_CHECK_NO_PREV,
316 xmlDebugErr(ctxt, XML_CHECK_NO_PREV,
320 xmlDebugErr(ctxt, XML_CHECK_WRONG_PREV,
327 xmlDebugErr(ctxt, XML_CHECK_NO_NEXT,
331 xmlDebugErr(ctxt, XML_CHECK_WRONG_NEXT,
334 xmlDebugErr(ctxt, XML_CHECK_WRONG_PARENT,
342 xmlCtxtNsCheckScope(ctxt, node, ns);
346 xmlCtxtNsCheckScope(ctxt, node, node->ns);
349 xmlCtxtNsCheckScope(ctxt, node, node->ns);
361 xmlCtxtCheckString(ctxt, (const xmlChar *) node->content);
366 xmlCtxtCheckName(ctxt, node->name);
373 if ((ctxt->dict != NULL) &&
374 (node->name == xmlDictLookup(ctxt->dict, BAD_CAST "nbktext",
378 xmlDebugErr3(ctxt, XML_CHECK_WRONG_NAME,
385 xmlDebugErr3(ctxt, XML_CHECK_WRONG_NAME,
390 xmlCtxtCheckName(ctxt, node->name);
395 xmlDebugErr3(ctxt, XML_CHECK_NAME_NOT_NULL,
421 xmlCtxtDumpString(xmlDebugCtxtPtr ctxt, const xmlChar * str)
425 if (ctxt->check) {
430 fprintf(ctxt->output, "(NULL)");
437 fputc(' ', ctxt->output);
439 fprintf(ctxt->output, "#%X", str[i]);
441 fputc(str[i], ctxt->output);
442 fprintf(ctxt->output, "...");
446 xmlCtxtDumpDtdNode(xmlDebugCtxtPtr ctxt, xmlDtdPtr dtd)
448 xmlCtxtDumpSpaces(ctxt);
451 if (!ctxt->check)
452 fprintf(ctxt->output, "DTD node is NULL\n");
457 xmlDebugErr(ctxt, XML_CHECK_NOT_DTD,
461 if (!ctxt->check) {
463 fprintf(ctxt->output, "DTD(%s)", (char *) dtd->name);
465 fprintf(ctxt->output, "DTD");
467 fprintf(ctxt->output, ", PUBLIC %s", (char *) dtd->ExternalID);
469 fprintf(ctxt->output, ", SYSTEM %s", (char *) dtd->SystemID);
470 fprintf(ctxt->output, "\n");
475 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) dtd);
479 xmlCtxtDumpAttrDecl(xmlDebugCtxtPtr ctxt, xmlAttributePtr attr)
481 xmlCtxtDumpSpaces(ctxt);
484 if (!ctxt->check)
485 fprintf(ctxt->output, "Attribute declaration is NULL\n");
489 xmlDebugErr(ctxt, XML_CHECK_NOT_ATTR_DECL,
494 if (!ctxt->check)
495 fprintf(ctxt->output, "ATTRDECL(%s)", (char *) attr->name);
497 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
500 if (!ctxt->check)
501 fprintf(ctxt->output, " for %s", (char *) attr->elem);
503 xmlDebugErr(ctxt, XML_CHECK_NO_ELEM,
505 if (!ctxt->check) {
508 fprintf(ctxt->output, " CDATA");
511 fprintf(ctxt->output, " ID");
514 fprintf(ctxt->output, " IDREF");
517 fprintf(ctxt->output, " IDREFS");
520 fprintf(ctxt->output, " ENTITY");
523 fprintf(ctxt->output, " ENTITIES");
526 fprintf(ctxt->output, " NMTOKEN");
529 fprintf(ctxt->output, " NMTOKENS");
532 fprintf(ctxt->output, " ENUMERATION");
535 fprintf(ctxt->output, " NOTATION ");
544 fprintf(ctxt->output, "|%s", (char *) cur->name);
546 fprintf(ctxt->output, " (%s", (char *) cur->name);
552 fprintf(ctxt->output, ")");
554 fprintf(ctxt->output, "...)");
560 fprintf(ctxt->output, " REQUIRED");
563 fprintf(ctxt->output, " IMPLIED");
566 fprintf(ctxt->output, " FIXED");
570 fprintf(ctxt->output, "\"");
571 xmlCtxtDumpString(ctxt
572 fprintf(ctxt->output, "\"");
574 fprintf(ctxt->output, "\n");
580 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) attr);
584 xmlCtxtDumpElemDecl(xmlDebugCtxtPtr ctxt, xmlElementPtr elem)
586 xmlCtxtDumpSpaces(ctxt);
589 if (!ctxt->check)
590 fprintf(ctxt->output, "Element declaration is NULL\n");
594 xmlDebugErr(ctxt, XML_CHECK_NOT_ELEM_DECL,
599 if (!ctxt->check) {
600 fprintf(ctxt->output, "ELEMDECL(");
601 xmlCtxtDumpString(ctxt, elem->name);
602 fprintf(ctxt->output, ")");
605 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
607 if (!ctxt->check) {
610 fprintf(ctxt->output, ", UNDEFINED");
613 fprintf(ctxt->output, ", EMPTY");
616 fprintf(ctxt->output, ", ANY");
619 fprintf(ctxt->output, ", MIXED ");
622 fprintf(ctxt->output, ", MIXED ");
631 fprintf(ctxt->output, "%s", buf);
633 fprintf(ctxt->output, "\n");
639 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) elem);
643 xmlCtxtDumpEntityDecl(xmlDebugCtxtPtr ctxt, xmlEntityPtr ent)
645 xmlCtxtDumpSpaces(ctxt);
648 if (!ctxt->check)
649 fprintf(ctxt->output, "Entity declaration is NULL\n");
653 xmlDebugErr(ctxt, XML_CHECK_NOT_ENTITY_DECL,
658 if (!ctxt->check) {
659 fprintf(ctxt->output, "ENTITYDECL(");
660 xmlCtxtDumpString(ctxt, ent->name);
661 fprintf(ctxt->output, ")");
664 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
666 if (!ctxt->check) {
669 fprintf(ctxt->output, ", internal\n");
672 fprintf(ctxt->output, ", external parsed\n");
675 fprintf(ctxt->output, ", unparsed\n");
678 fprintf(ctxt->output, ", parameter\n");
681 fprintf(ctxt->output, ", external parameter\n");
684 fprintf(ctxt->output, ", predefined\n");
688 xmlCtxtDumpSpaces(ctxt);
689 fprintf(ctxt->output, " ExternalID=%s\n",
693 xmlCtxtDumpSpaces(ctxt);
694 fprintf(ctxt->output, " SystemID=%s\n",
698 xmlCtxtDumpSpaces(ctxt);
699 fprintf(ctxt->output, " URI=%s\n", (char *) ent->URI);
702 xmlCtxtDumpSpaces(ctxt);
703 fprintf(ctxt->output, " content=");
704 xmlCtxtDumpString(ctxt, ent->content);
705 fprintf(ctxt->output, "\n");
712 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) ent);
716 xmlCtxtDumpNamespace(xmlDebugCtxtPtr ctxt, xmlNsPtr ns)
718 xmlCtxtDumpSpaces(ctxt);
721 if (!ctxt->check)
722 fprintf(ctxt->output, "namespace node is NULL\n");
726 xmlDebugErr(ctxt, XML_CHECK_NOT_NS_DECL,
732 xmlDebugErr3(ctxt, XML_CHECK_NO_HREF,
736 xmlDebugErr(ctxt, XML_CHECK_NO_HREF,
739 if (!ctxt->check) {
741 fprintf(ctxt->output, "namespace %s href=",
744 fprintf(ctxt->output, "default namespace href=");
746 xmlCtxtDumpString(ctxt, ns->href);
747 fprintf(ctxt->output, "\n");
753 xmlCtxtDumpNamespaceList(xmlDebugCtxtPtr ctxt, xmlNsPtr ns)
756 xmlCtxtDumpNamespace(ctxt, ns);
762 xmlCtxtDumpEntity(xmlDebugCtxtPtr ctxt, xmlEntityPtr ent)
764 xmlCtxtDumpSpaces(ctxt);
767 if (!ctxt->check)
768 fprintf(ctxt->output, "Entity is NULL\n");
771 if (!ctxt->check) {
774 fprintf(ctxt->output, "INTERNAL_GENERAL_ENTITY ");
777 fprintf(ctxt->output, "EXTERNAL_GENERAL_PARSED_ENTITY ");
780 fprintf(ctxt->output, "EXTERNAL_GENERAL_UNPARSED_ENTITY ");
783 fprintf(ctxt->output, "INTERNAL_PARAMETER_ENTITY ");
786 fprintf(ctxt->output, "EXTERNAL_PARAMETER_ENTITY ");
789 fprintf(ctxt->output, "ENTITY_%d ! ", (int) ent->etype);
791 fprintf(ctxt->output, "%s\n", ent->name);
793 xmlCtxtDumpSpaces(ctxt);
794 fprintf(ctxt->output, "ExternalID=%s\n",
798 xmlCtxtDumpSpaces(ctxt);
799 fprintf(ctxt->output, "SystemID=%s\n", (char *) ent->SystemID);
802 xmlCtxtDumpSpaces(ctxt);
803 fprintf(ctxt->output, "URI=%s\n", (char *) ent->URI);
806 xmlCtxtDumpSpaces(ctxt);
807 fprintf(ctxt->output, "content=");
808 xmlCtxtDumpString(ctxt, ent->content);
809 fprintf(ctxt->output, "\n");
823 xmlCtxtDumpAttr(xmlDebugCtxtPtr ctxt, xmlAttrPtr attr)
825 xmlCtxtDumpSpaces(ctxt);
828 if (!ctxt->check)
829 fprintf(ctxt->output, "Attr is NULL");
832 if (!ctxt->check) {
833 fprintf(ctxt->output, "ATTRIBUTE ");
834 xmlCtxtDumpString(ctxt, attr->name);
835 fprintf(ctxt->output, "\n");
837 ctxt->depth++;
838 xmlCtxtDumpNodeList(ctxt, attr->children);
839 ctxt->depth--;
843 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
849 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) attr);
861 xmlCtxtDumpAttrList(xmlDebugCtxtPtr ctxt, xmlAttrPtr attr)
864 xmlCtxtDumpAttr(ctxt, attr);
878 xmlCtxtDumpOneNode(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
881 if (!ctxt->check) {
882 xmlCtxtDumpSpaces(ctxt);
883 fprintf(ctxt->output, "node is NULL\n");
887 ctxt->node = node;
891 if (!ctxt->check) {
892 xmlCtxtDumpSpaces(ctxt);
893 fprintf(ctxt->output, "ELEMENT ");
895 xmlCtxtDumpString(ctxt, node->ns->prefix);
896 fprintf(ctxt->output, ":");
898 xmlCtxtDumpString(ctxt, node->name);
899 fprintf(ctxt->output, "\n");
903 if (!ctxt->check)
904 xmlCtxtDumpSpaces(ctxt);
905 fprintf(ctxt->output, "Error, ATTRIBUTE found here\n");
906 xmlCtxtGenericNodeCheck(ctxt, node);
909 if (!ctxt->check) {
910 xmlCtxtDumpSpaces(ctxt);
912 fprintf(ctxt->output, "TEXT no enc");
914 fprintf(ctxt->output, "TEXT");
915 if (ctxt->options & DUMP_TEXT_TYPE) {
917 fprintf(ctxt->output, " compact\n");
918 else if (xmlDictOwns(ctxt->dict, node->content) == 1)
919 fprintf(ctxt->output, " interned\n");
921 fprintf(ctxt->output, "\n");
923 fprintf(ctxt->output, "\n");
927 if (!ctxt->check) {
928 xmlCtxtDumpSpaces(ctxt);
929 fprintf(ctxt->output, "CDATA_SECTION\n");
933 if (!ctxt->check) {
934 xmlCtxtDumpSpaces(ctxt);
935 fprintf(ctxt->output, "ENTITY_REF(%s)\n",
940 if (!ctxt->check) {
941 xmlCtxtDumpSpaces(ctxt);
942 fprintf(ctxt->output, "ENTITY\n");
946 if (!ctxt->check) {
947 xmlCtxtDumpSpaces(ctxt);
948 fprintf(ctxt->output, "PI %s\n", (char *) node->name);
952 if (!ctxt->check) {
953 xmlCtxtDumpSpaces(ctxt);
954 fprintf(ctxt->output, "COMMENT\n");
959 if (!ctxt->check) {
960 xmlCtxtDumpSpaces(ctxt);
962 fprintf(ctxt->output, "Error, DOCUMENT found here\n");
963 xmlCtxtGenericNodeCheck(ctxt, node);
966 if (!ctxt->check) {
967 xmlCtxtDumpSpaces(ctxt);
968 fprintf(ctxt->output, "DOCUMENT_TYPE\n");
972 if (!ctxt->check) {
973 xmlCtxtDumpSpaces(ctxt);
974 fprintf(ctxt->output, "DOCUMENT_FRAG\n");
978 if (!ctxt->check) {
979 xmlCtxtDumpSpaces(ctxt);
980 fprintf(ctxt->output, "NOTATION\n");
984 xmlCtxtDumpDtdNode(ctxt, (xmlDtdPtr) node);
987 xmlCtxtDumpElemDecl(ctxt, (xmlElementPtr) node);
990 xmlCtxtDumpAttrDecl(ctxt, (xmlAttributePtr) node);
993 xmlCtxtDumpEntityDecl(ctxt, (xmlEntityPtr) node);
996 xmlCtxtDumpNamespace(ctxt, (xmlNsPtr) node);
999 if (!ctxt->check) {
1000 xmlCtxtDumpSpaces(ctxt);
1001 fprintf(ctxt->output, "INCLUDE START\n");
1005 if (!ctxt->check) {
1006 xmlCtxtDumpSpaces(ctxt);
1007 fprintf(ctxt->output, "INCLUDE END\n");
1011 if (!ctxt->check)
1012 xmlCtxtDumpSpaces(ctxt);
1013 xmlDebugErr2(ctxt, XML_CHECK_UNKNOWN_NODE,
1018 if (!ctxt->check) {
1019 xmlCtxtDumpSpaces(ctxt);
1021 fprintf(ctxt->output, "PBM: doc == NULL !!!\n");
1023 ctxt->depth++;
1025 xmlCtxtDumpNamespaceList(ctxt, node->nsDef);
1027 xmlCtxtDumpAttrList(ctxt, node->properties);
1030 if (!ctxt->check) {
1031 xmlCtxtDumpSpaces(ctxt);
1032 fprintf(ctxt->output, "content=");
1033 xmlCtxtDumpString(ctxt, node->content);
1034 fprintf(ctxt->output, "\n");
1042 xmlCtxtDumpEntity(ctxt, ent);
1044 ctxt->depth--;
1049 xmlCtxtGenericNodeCheck(ctxt, node);
1061 xmlCtxtDumpNode(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
1064 if (!ctxt->check) {
1065 xmlCtxtDumpSpaces(ctxt);
1066 fprintf(ctxt->output, "node is NULL\n");
1070 xmlCtxtDumpOneNode(ctxt, node);
1073 ctxt->depth++;
1074 xmlCtxtDumpNodeList(ctxt, node->children);
1075 ctxt->depth--;
1088 xmlCtxtDumpNodeList(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
1091 xmlCtxtDumpNode(ctxt, node);
1097 xmlCtxtDumpDocHead(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1100 if (!ctxt->check)
1101 fprintf(ctxt->output, "DOCUMENT == NULL !\n");
1104 ctxt->node = (xmlNodePtr) doc;
1108 xmlDebugErr(ctxt, XML_CHECK_FOUND_ELEMENT,
1112 xmlDebugErr(ctxt, XML_CHECK_FOUND_ATTRIBUTE,
1116 xmlDebugErr(ctxt, XML_CHECK_FOUND_TEXT,
1120 xmlDebugErr(ctxt, XML_CHECK_FOUND_CDATA,
1124 xmlDebugErr(ctxt, XML_CHECK_FOUND_ENTITYREF,
1128 xmlDebugErr(ctxt, XML_CHECK_FOUND_ENTITY,
1132 xmlDebugErr(ctxt, XML_CHECK_FOUND_PI,
1136 xmlDebugErr(ctxt, XML_CHECK_FOUND_COMMENT,
1140 if (!ctxt->check)
1141 fprintf(ctxt->output, "DOCUMENT\n");
1144 if (!ctxt->check)
1145 fprintf(ctxt->output, "HTML DOCUMENT\n");
1148 xmlDebugErr(ctxt, XML_CHECK_FOUND_DOCTYPE,
1152 xmlDebugErr(ctxt, XML_CHECK_FOUND_FRAGMENT,
1156 xmlDebugErr(ctxt, XML_CHECK_FOUND_NOTATION,
1160 xmlDebugErr2(ctxt, XML_CHECK_UNKNOWN_NODE,
1173 xmlCtxtDumpDocumentHead(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1176 xmlCtxtDumpDocHead(ctxt, doc);
1177 if (!ctxt->check) {
1179 fprintf(ctxt->output, "name=");
1180 xmlCtxtDumpString(ctxt, BAD_CAST doc->name);
1181 fprintf(ctxt->output, "\n");
1184 fprintf(ctxt->output, "version=");
1185 xmlCtxtDumpString(ctxt, doc->version);
1186 fprintf(ctxt->output, "\n");
1189 fprintf(ctxt->output, "encoding=");
1190 xmlCtxtDumpString(ctxt, doc->encoding);
1191 fprintf(ctxt->output, "\n");
1194 fprintf(ctxt->output, "URL=");
1195 xmlCtxtDumpString(ctxt, doc->URL);
1196 fprintf(ctxt->output, "\n");
1199 fprintf(ctxt->output, "standalone=true\n");
1202 xmlCtxtDumpNamespaceList(ctxt, doc->oldNs);
1213 xmlCtxtDumpDocument(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1216 if (!ctxt->check)
1217 fprintf(ctxt->output, "DOCUMENT == NULL !\n");
1220 xmlCtxtDumpDocumentHead(ctxt, doc);
1224 ctxt->depth++;
1225 xmlCtxtDumpNodeList(ctxt, doc->children);
1226 ctxt->depth--;
1231 xmlCtxtDumpEntityCallback(xmlEntityPtr cur, xmlDebugCtxtPtr ctxt)
1234 if (!ctxt->check)
1235 fprintf(ctxt->output, "Entity is NULL");
1238 if (!ctxt->check) {
1239 fprintf(ctxt->output, "%s : ", (char *) cur->name);
1242 fprintf(ctxt->output, "INTERNAL GENERAL, ");
1245 fprintf(ctxt->output, "EXTERNAL PARSED, ");
1248 fprintf(ctxt->output, "EXTERNAL UNPARSED, ");
1251 fprintf(ctxt->output, "INTERNAL PARAMETER, ");
1254 fprintf(ctxt->output, "EXTERNAL PARAMETER, ");
1257 xmlDebugErr2(ctxt, XML_CHECK_ENTITY_TYPE,
1261 fprintf(ctxt->output, "ID \"%s\"", (char *) cur->ExternalID);
1263 fprintf(ctxt->output, "SYSTEM \"%s\"", (char *) cur->SystemID);
1265 fprintf(ctxt->output, "\n orig \"%s\"", (char *) cur->orig);
1267 fprintf(ctxt->output, "\n content \"%s\"",
1269 fprintf(ctxt->output, "\n");
1281 xmlCtxtDumpEntities(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1284 xmlCtxtDumpDocHead(ctxt, doc);
1289 if (!ctxt->check)
1290 fprintf(ctxt->output, "Entities in internal subset\n");
1292 ctxt);
1294 fprintf(ctxt->output, "No entities in internal subset\n");
1299 if (!ctxt->check)
1300 fprintf(ctxt->output, "Entities in external subset\n");
1302 ctxt);
1303 } else if (!ctxt->check)
1304 fprintf(ctxt->output, "No entities in external subset\n");
1315 xmlCtxtDumpDTD(xmlDebugCtxtPtr ctxt, xmlDtdPtr dtd)
1318 if (!ctxt->check)
1319 fprintf(ctxt->output, "DTD is NULL\n");
1322 xmlCtxtDumpDtdNode(ctxt, dtd);
1324 fprintf(ctxt->output, " DTD is empty\n");
1326 ctxt->depth++;
1327 xmlCtxtDumpNodeList(ctxt, dtd->children);
1328 ctxt->depth--;
1378 xmlDebugCtxt ctxt;
1381 xmlCtxtDumpInitCtxt(&ctxt);
1382 ctxt.output = output;
1383 ctxt.depth = depth;
1384 xmlCtxtDumpAttr(&ctxt, attr);
1385 xmlCtxtDumpCleanCtxt(&ctxt);
1399 xmlDebugCtxt ctxt;
1402 xmlCtxtDumpInitCtxt(&ctxt);
1403 ctxt.output = output;
1404 xmlCtxtDumpEntities(&ctxt, doc);
1405 xmlCtxtDumpCleanCtxt(&ctxt);
1419 xmlDebugCtxt ctxt;
1422 xmlCtxtDumpInitCtxt(&ctxt);
1423 ctxt.output = output;
1424 ctxt.depth = depth;
1425 xmlCtxtDumpAttrList(&ctxt, attr);
1426 xmlCtxtDumpCleanCtxt(&ctxt);
1440 xmlDebugCtxt ctxt;
1443 xmlCtxtDumpInitCtxt(&ctxt);
1444 ctxt.output = output;
1445 ctxt.depth = depth;
1446 xmlCtxtDumpOneNode(&ctxt, node);
1447 xmlCtxtDumpCleanCtxt(&ctxt);
1461 xmlDebugCtxt ctxt;
1465 xmlCtxtDumpInitCtxt(&ctxt);
1466 ctxt.output = output;
1467 ctxt.depth = depth;
1468 xmlCtxtDumpNode(&ctxt, node);
1469 xmlCtxtDumpCleanCtxt(&ctxt);
1483 xmlDebugCtxt ctxt;
1487 xmlCtxtDumpInitCtxt(&ctxt);
1488 ctxt.output = output;
1489 ctxt.depth = depth;
1490 xmlCtxtDumpNodeList(&ctxt, node);
1491 xmlCtxtDumpCleanCtxt(&ctxt);
1504 xmlDebugCtxt ctxt;
1508 xmlCtxtDumpInitCtxt(&ctxt);
1509 ctxt.options |= DUMP_TEXT_TYPE;
1510 ctxt.output = output;
1511 xmlCtxtDumpDocumentHead(&ctxt, doc);
1512 xmlCtxtDumpCleanCtxt(&ctxt);
1525 xmlDebugCtxt ctxt;
1529 xmlCtxtDumpInitCtxt(&ctxt);
1530 ctxt.options |= DUMP_TEXT_TYPE;
1531 ctxt.output = output;
1532 xmlCtxtDumpDocument(&ctxt, doc);
1533 xmlCtxtDumpCleanCtxt(&ctxt);
1546 xmlDebugCtxt ctxt;
1550 xmlCtxtDumpInitCtxt(&ctxt);
1551 ctxt.options |= DUMP_TEXT_TYPE;
1552 ctxt.output = output;
1553 xmlCtxtDumpDTD(&ctxt, dtd);
1554 xmlCtxtDumpCleanCtxt(&ctxt);
1576 xmlDebugCtxt ctxt;
1580 xmlCtxtDumpInitCtxt(&ctxt);
1581 ctxt.output = output;
1582 ctxt.check = 1;
1583 xmlCtxtDumpDocument(&ctxt, doc);
1584 xmlCtxtDumpCleanCtxt(&ctxt);
1585 return(ctxt.errors);
1880 * @ctxt : a non-null shell context
1886 xmlShellPrintNodeCtxt(xmlShellCtxtPtr ctxt,xmlNodePtr node)
1892 if (ctxt == NULL)
1895 fp = ctxt->output;
1922 * @ctxt: a valid shell context
1928 xmlShellPrintXPathResultCtxt(xmlShellCtxtPtr ctxt,xmlXPathObjectPtr list)
1930 if (!ctxt)
1942 xmlShellPrintNodeCtxt(ctxt,
1989 * @ctxt: the shell context
2000 xmlShellList(xmlShellCtxtPtr ctxt,
2005 if (!ctxt)
2008 fprintf(ctxt->output, "NULL\n");
2015 xmlLsOneNode(ctxt->output, node);
2020 xmlLsOneNode(ctxt->output, node);
2024 xmlLsOneNode(ctxt->output, cur);
2032 * @ctxt: the shell context
2043 xmlShellBase(xmlShellCtxtPtr ctxt,
2048 if (!ctxt)
2051 fprintf(ctxt->output, "NULL\n");
2058 fprintf(ctxt->output, " No base found !!!\n");
2060 fprintf(ctxt->output, "%s\n", base);
2069 * @ctxt: the shell context
2080 xmlShellSetBase(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2092 * @ctxt: the shell context
2104 xmlShellRegisterNamespace(xmlShellCtxtPtr ctxt, char *arg,
2123 fprintf(ctxt->output, "setns: prefix=[nsuri] required\n");
2137 if(xmlXPathRegisterNs(ctxt->pctxt, prefix, href) != 0) {
2138 fprintf(ctxt->output,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", prefix, href);
2149 * @ctxt: the shell context
2160 xmlShellRegisterRootNamespaces(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_UNUSED,
2166 (root->nsDef == NULL) || (ctxt == NULL) || (ctxt->pctxt == NULL))
2171 xmlXPathRegisterNs(ctxt->pctxt, BAD_CAST "defaultns", ns->href);
2173 xmlXPathRegisterNs(ctxt->pctxt, ns->prefix, ns->href);
2182 * @ctxt: the shell context
2193 xmlShellGrep(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2196 if (!ctxt)
2213 fprintf(ctxt->output, "%s : ", xmlGetNodePath(node));
2214 xmlShellList(ctxt, NULL, node, NULL);
2219 fprintf(ctxt->output, "%s : ", xmlGetNodePath(node->parent));
2220 xmlShellList(ctxt, NULL, node->parent, NULL);
2260 * @ctxt: the shell context
2271 xmlShellDir(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2275 if (!ctxt)
2278 fprintf(ctxt->output, "NULL\n");
2283 xmlDebugDumpDocumentHead(ctxt->output, (xmlDocPtr) node);
2285 xmlDebugDumpAttr(ctxt->output, (xmlAttrPtr) node, 0);
2287 xmlDebugDumpOneNode(ctxt->output, node, 0);
2294 * @ctxt: the shell context
2305 xmlShellSetContent(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2312 if (!ctxt)
2315 fprintf(ctxt->output, "NULL\n");
2319 fprintf(ctxt->output, "NULL\n");
2332 fprintf(ctxt->output, "failed to parse content\n");
2340 * @ctxt: the shell context
2356 xmlRelaxNGParserCtxtPtr ctxt;
2360 ctxt = xmlRelaxNGNewParserCtxt(schemas);
2361 xmlRelaxNGSetParserErrors(ctxt,
2365 relaxngschemas = xmlRelaxNGParse(ctxt);
2366 xmlRelaxNGFreeParserCtxt(ctxt);
2396 * @ctxt: the shell context
2407 xmlShellCat(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_UNUSED,
2410 if (!ctxt)
2413 fprintf(ctxt->output, "NULL\n");
2416 if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) {
2419 htmlDocDump(ctxt->output, (htmlDocPtr) node);
2421 htmlNodeDumpFile(ctxt->output, ctxt->doc, node);
2424 xmlDocDump(ctxt->output, (xmlDocPtr) node);
2426 xmlElemDump(ctxt->output, ctxt->doc, node);
2430 xmlDocDump(ctxt->output, (xmlDocPtr) node);
2432 xmlElemDump(ctxt->output, ctxt->doc, node);
2434 fprintf(ctxt->output, "\n");
2441 * @ctxt: the shell context
2452 xmlShellLoad(xmlShellCtxtPtr ctxt, char *filename,
2459 if ((ctxt == NULL) || (filename == NULL)) return(-1);
2460 if (ctxt->doc != NULL)
2461 html = (ctxt->doc->type == XML_HTML_DOCUMENT_NODE);
2467 fprintf(ctxt->output, "HTML support not compiled in\n");
2474 if (ctxt->loaded == 1) {
2475 xmlFreeDoc(ctxt->doc);
2477 ctxt->loaded = 1;
2479 xmlXPathFreeContext(ctxt->pctxt);
2481 xmlFree(ctxt->filename);
2482 ctxt->doc = doc;
2483 ctxt->node = (xmlNodePtr) doc;
2485 ctxt->pctxt = xmlXPathNewContext(doc);
2487 ctxt->filename = (char *) xmlCanonicPath((xmlChar *) filename);
2496 * @ctxt: the shell context
2508 xmlShellWrite(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
2525 if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
2533 if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
2539 if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
2555 xmlElemDump(f, ctxt->doc, node);
2564 * @ctxt: the shell context
2575 xmlShellSave(xmlShellCtxtPtr ctxt, char *filename,
2579 if ((ctxt == NULL) || (ctxt->doc == NULL))
2582 filename = ctxt->filename;
2592 switch (ctxt->doc->type) {
2594 if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
2601 if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
2606 if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
2625 * @ctxt: the shell context
2637 xmlShellValidate(xmlShellCtxtPtr ctxt, char *dtd,
2644 if ((ctxt == NULL) || (ctxt->doc == NULL)) return(-1);
2650 res = xmlValidateDocument(&vctxt, ctxt->doc);
2656 res = xmlValidateDtd(&vctxt, ctxt->doc, subset);
2667 * @ctxt: the shell context
2679 xmlShellDu(xmlShellCtxtPtr ctxt,
2686 if (!ctxt)
2695 fprintf(ctxt->output, "/\n");
2698 fprintf(ctxt->output, " ");
2699 fprintf(ctxt->output, "%s\n", node->name);
2749 * @ctxt: the shell context
2762 xmlShellPwd(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED, char *buffer,
2809 xmlShellCtxtPtr ctxt;
2820 ctxt = (xmlShellCtxtPtr) xmlMalloc(sizeof(xmlShellCtxt));
2821 if (ctxt == NULL)
2823 ctxt->loaded = 0;
2824 ctxt->doc = doc;
2825 ctxt->input = input;
2826 ctxt->output = output;
2827 ctxt->filename = (char *) xmlStrdup((xmlChar *) filename);
2828 ctxt->node = (xmlNodePtr) ctxt->doc;
2831 ctxt->pctxt = xmlXPathNewContext(ctxt->doc);
2832 if (ctxt->pctxt == NULL) {
2833 xmlFree(ctxt);
2838 if (ctxt->node == (xmlNodePtr) ctxt->doc)
2840 else if ((ctxt->node != NULL) && (ctxt->node->name))
2841 snprintf(prompt, sizeof(prompt), "%s > ", ctxt->node->name);
2849 cmdline = ctxt->input(prompt);
2893 fprintf(ctxt->output, "\tbase display XML base of the node\n");
2894 fprintf(ctxt->output, "\tsetbase URI change the XML base of the node\n");
2895 fprintf(ctxt->output, "\tbye leave shell\n");
2896 fprintf(ctxt->output, "\tcat [node] display node or current node\n");
2897 fprintf(ctxt->output, "\tcd [path] change directory to path or to root\n");
2898 fprintf(ctxt->output, "\tdir [path] dumps informations about the node (namespace, attributes, content)\n");
2899 fprintf(ctxt->output, "\tdu [path] show the structure of the subtree under path or the current node\n");
2900 fprintf(ctxt->output, "\texit leave shell\n");
2901 fprintf(ctxt->output, "\thelp display this help\n");
2902 fprintf(ctxt->output, "\tfree display memory usage\n");
2903 fprintf(ctxt->output, "\tload [name] load a new document with name\n");
2904 fprintf(ctxt->output, "\tls [path] list contents of path or the current directory\n");
2905 fprintf(ctxt->output, "\tset xml_fragment replace the current node content with the fragment parsed in context\n");
2907 fprintf(ctxt->output, "\txpath expr evaluate the XPath expression in that context and print the result\n");
2908 fprintf(ctxt->output, "\tsetns nsreg register a namespace to a prefix in the XPath evaluation context\n");
2909 fprintf(ctxt->output, "\t format for nsreg is: prefix=[nsuri] (i.e. prefix= unsets a prefix)\n");
2910 fprintf(ctxt->output, "\tsetrootns register all namespace found on the root element\n");
2911 fprintf(ctxt->output, "\t the default namespace if any uses 'defaultns' prefix\n");
2913 fprintf(ctxt->output, "\tpwd display current working directory\n");
2914 fprintf(ctxt->output, "\tquit leave shell\n");
2916 fprintf(ctxt->output, "\tsave [name] save this document to name or the original name\n");
2917 fprintf(ctxt->output, "\twrite [name] write the current node to the filename\n");
2920 fprintf(ctxt->output, "\tvalidate check the document for errors\n");
2923 fprintf(ctxt->output, "\trelaxng rng validate the document agaisnt the Relax-NG schemas\n");
2925 fprintf(ctxt->output, "\tgrep string search for a string in the subtree\n");
2928 xmlShellValidate(ctxt, arg, NULL, NULL);
2931 xmlShellLoad(ctxt, arg, NULL, NULL);
2934 xmlShellRNGValidate(ctxt, arg, NULL, NULL);
2938 xmlShellSave(ctxt, arg, NULL, NULL);
2944 xmlShellWrite(ctxt, arg, ctxt->node, NULL);
2947 xmlShellGrep(ctxt, arg, ctxt->node, NULL);
2950 xmlMemShow(ctxt->output, 0);
2955 xmlMemShow(ctxt->output, len);
2960 if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL))
2961 fprintf(ctxt->output, "%s\n", dir);
2963 xmlShellDu(ctxt, NULL, ctxt->node, NULL);
2965 xmlShellBase(ctxt, NULL, ctxt->node, NULL);
2967 xmlShellSetContent(ctxt, arg, ctxt->node, NULL);
2974 xmlShellRegisterNamespace(ctxt, arg, NULL, NULL);
2979 root = xmlDocGetRootElement(ctxt->doc);
2980 xmlShellRegisterRootNamespaces(ctxt, NULL, root, NULL);
2986 ctxt->pctxt->node = ctxt->node;
2987 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
2988 xmlXPathDebugDumpObject(ctxt->output, list, 0);
2994 xmlShellSetBase(ctxt, arg, ctxt->node, NULL);
3001 xmlShellDir(ctxt, NULL, ctxt->node, NULL);
3003 xmlShellList(ctxt, NULL, ctxt->node, NULL);
3005 ctxt->pctxt->node = ctxt->node;
3007 ctxt->pctxt->node = ctxt->node;
3008 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3028 xmlShellDir(ctxt, NULL,
3032 xmlShellList(ctxt, NULL,
3079 ctxt->pctxt->node = NULL;
3083 ctxt->node = (xmlNodePtr) ctxt->doc;
3086 ctxt->pctxt->node = ctxt->node;
3087 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3100 ctxt->node = list->nodesetval->nodeTab[0];
3101 if ((ctxt->node != NULL) &&
3102 (ctxt->node->type ==
3106 ctxt->node = NULL;
3159 ctxt->pctxt->node = NULL;
3164 xmlShellCat(ctxt, NULL, ctxt->node, NULL);
3166 ctxt->pctxt->node = ctxt->node;
3168 ctxt->pctxt->node = ctxt->node;
3169 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3189 fprintf(ctxt->output, " -------\n");
3190 xmlShellCat(ctxt, NULL,
3237 ctxt->pctxt->node = NULL;
3248 xmlXPathFreeContext(ctxt->pctxt);
3250 if (ctxt->loaded) {
3251 xmlFreeDoc(ctxt->doc);
3253 if (ctxt->filename != NULL)
3254 xmlFree(ctxt->filename);
3255 xmlFree(ctxt);