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, &ctxt->shift[100 - 2 * ctxt->depth]);
146 fprintf(ctxt->output, 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 xmlDebugErr3(ctxt, XML_CHECK_OUTSIDE_DICT,
271 xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) {
278 xmlDebugErr(ctxt, XML_CHECK_NO_PARENT,
281 xmlDebugErr(ctxt, XML_CHECK_NO_DOC,
286 if ((dict == NULL) && (ctxt->nodict == 0)) {
290 xmlDebugErr(ctxt, XML_CHECK_NO_DICT,
293 ctxt->nodict = 1;
295 if (ctxt->doc == NULL)
296 ctxt->doc = doc;
298 if (ctxt->dict == NULL) {
299 ctxt->dict = dict;
304 xmlDebugErr(ctxt, XML_CHECK_WRONG_DOC,
310 xmlDebugErr(ctxt, XML_CHECK_NO_PREV,
314 xmlDebugErr(ctxt, XML_CHECK_NO_PREV,
318 xmlDebugErr(ctxt, XML_CHECK_WRONG_PREV,
324 xmlDebugErr(ctxt, XML_CHECK_NO_NEXT,
328 xmlDebugErr(ctxt, XML_CHECK_WRONG_NEXT,
331 xmlDebugErr(ctxt, XML_CHECK_WRONG_PARENT,
339 xmlCtxtNsCheckScope(ctxt, node, ns);
343 xmlCtxtNsCheckScope(ctxt, node, node->ns);
346 xmlCtxtNsCheckScope(ctxt, node, node->ns);
358 xmlCtxtCheckString(ctxt, (const xmlChar *) node->content);
363 xmlCtxtCheckName(ctxt, node->name);
370 if ((ctxt->dict != NULL) &&
371 (node->name == xmlDictLookup(ctxt->dict, BAD_CAST "nbktext",
375 xmlDebugErr3(ctxt, XML_CHECK_WRONG_NAME,
382 xmlDebugErr3(ctxt, XML_CHECK_WRONG_NAME,
387 xmlCtxtCheckName(ctxt, node->name);
392 xmlDebugErr3(ctxt, XML_CHECK_NAME_NOT_NULL,
418 xmlCtxtDumpString(xmlDebugCtxtPtr ctxt, const xmlChar * str)
422 if (ctxt->check) {
427 fprintf(ctxt->output, "(NULL)");
434 fputc(' ', ctxt->output);
436 fprintf(ctxt->output, "#%X", str[i]);
438 fputc(str[i], ctxt->output);
439 fprintf(ctxt->output, "...");
443 xmlCtxtDumpDtdNode(xmlDebugCtxtPtr ctxt, xmlDtdPtr dtd)
445 xmlCtxtDumpSpaces(ctxt);
448 if (!ctxt->check)
449 fprintf(ctxt->output, "DTD node is NULL\n");
454 xmlDebugErr(ctxt, XML_CHECK_NOT_DTD,
458 if (!ctxt->check) {
460 fprintf(ctxt->output, "DTD(%s)", (char *) dtd->name);
462 fprintf(ctxt->output, "DTD");
464 fprintf(ctxt->output, ", PUBLIC %s", (char *) dtd->ExternalID);
466 fprintf(ctxt->output, ", SYSTEM %s", (char *) dtd->SystemID);
467 fprintf(ctxt->output, "\n");
472 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) dtd);
476 xmlCtxtDumpAttrDecl(xmlDebugCtxtPtr ctxt, xmlAttributePtr attr)
478 xmlCtxtDumpSpaces(ctxt);
481 if (!ctxt->check)
482 fprintf(ctxt->output, "Attribute declaration is NULL\n");
486 xmlDebugErr(ctxt, XML_CHECK_NOT_ATTR_DECL,
491 if (!ctxt->check)
492 fprintf(ctxt->output, "ATTRDECL(%s)", (char *) attr->name);
494 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
497 if (!ctxt->check)
498 fprintf(ctxt->output, " for %s", (char *) attr->elem);
500 xmlDebugErr(ctxt, XML_CHECK_NO_ELEM,
502 if (!ctxt->check) {
505 fprintf(ctxt->output, " CDATA");
508 fprintf(ctxt->output, " ID");
511 fprintf(ctxt->output, " IDREF");
514 fprintf(ctxt->output, " IDREFS");
517 fprintf(ctxt->output, " ENTITY");
520 fprintf(ctxt->output, " ENTITIES");
523 fprintf(ctxt->output, " NMTOKEN");
526 fprintf(ctxt->output, " NMTOKENS");
529 fprintf(ctxt->output, " ENUMERATION");
532 fprintf(ctxt->output, " NOTATION ");
541 fprintf(ctxt->output, "|%s", (char *) cur->name);
543 fprintf(ctxt->output, " (%s", (char *) cur->name);
549 fprintf(ctxt->output, ")");
551 fprintf(ctxt->output, "...)");
557 fprintf(ctxt->output, " REQUIRED");
560 fprintf(ctxt->output, " IMPLIED");
563 fprintf(ctxt->output, " FIXED");
567 fprintf(ctxt->output, "\"");
568 xmlCtxtDumpString(ctxt, attr->defaultValue);
569 fprintf(ctxt->output, "\"");
571 fprintf(ctxt->output, "\n");
577 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) attr);
581 xmlCtxtDumpElemDecl(xmlDebugCtxtPtr ctxt, xmlElementPtr elem)
583 xmlCtxtDumpSpaces(ctxt);
586 if (!ctxt->check)
587 fprintf(ctxt->output, "Element declaration is NULL\n");
591 xmlDebugErr(ctxt, XML_CHECK_NOT_ELEM_DECL,
596 if (!ctxt->check) {
597 fprintf(ctxt->output, "ELEMDECL(");
598 xmlCtxtDumpString(ctxt, elem->name);
599 fprintf(ctxt->output, ")");
602 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
604 if (!ctxt->check) {
607 fprintf(ctxt->output, ", UNDEFINED");
610 fprintf(ctxt->output, ", EMPTY");
613 fprintf(ctxt->output, ", ANY");
616 fprintf(ctxt->output, ", MIXED ");
619 fprintf(ctxt->output, ", MIXED ");
628 fprintf(ctxt->output, "%s", buf);
630 fprintf(ctxt->output, "\n");
636 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) elem);
640 xmlCtxtDumpEntityDecl(xmlDebugCtxtPtr ctxt, xmlEntityPtr ent)
642 xmlCtxtDumpSpaces(ctxt);
645 if (!ctxt->check)
646 fprintf(ctxt->output, "Entity declaration is NULL\n");
650 xmlDebugErr(ctxt, XML_CHECK_NOT_ENTITY_DECL,
655 if (!ctxt->check) {
656 fprintf(ctxt->output, "ENTITYDECL(");
657 xmlCtxtDumpString(ctxt, ent->name);
658 fprintf(ctxt->output, ")");
661 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
663 if (!ctxt->check) {
666 fprintf(ctxt->output, ", internal\n");
669 fprintf(ctxt->output, ", external parsed\n");
672 fprintf(ctxt->output, ", unparsed\n");
675 fprintf(ctxt->output, ", parameter\n");
678 fprintf(ctxt->output, ", external parameter\n");
681 fprintf(ctxt->output, ", predefined\n");
685 xmlCtxtDumpSpaces(ctxt);
686 fprintf(ctxt->output, " ExternalID=%s\n",
690 xmlCtxtDumpSpaces(ctxt);
691 fprintf(ctxt->output, " SystemID=%s\n",
695 xmlCtxtDumpSpaces(ctxt);
696 fprintf(ctxt->output, " URI=%s\n", (char *) ent->URI);
699 xmlCtxtDumpSpaces(ctxt);
700 fprintf(ctxt->output, " content=");
701 xmlCtxtDumpString(ctxt, ent->content);
702 fprintf(ctxt->output, "\n");
709 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) ent);
713 xmlCtxtDumpNamespace(xmlDebugCtxtPtr ctxt, xmlNsPtr ns)
715 xmlCtxtDumpSpaces(ctxt);
718 if (!ctxt->check)
719 fprintf(ctxt->output, "namespace node is NULL\n");
723 xmlDebugErr(ctxt, XML_CHECK_NOT_NS_DECL,
729 xmlDebugErr3(ctxt, XML_CHECK_NO_HREF,
733 xmlDebugErr(ctxt, XML_CHECK_NO_HREF,
736 if (!ctxt->check) {
738 fprintf(ctxt->output, "namespace %s href=",
741 fprintf(ctxt->output, "default namespace href=");
743 xmlCtxtDumpString(ctxt, ns->href);
744 fprintf(ctxt->output, "\n");
750 xmlCtxtDumpNamespaceList(xmlDebugCtxtPtr ctxt, xmlNsPtr ns)
753 xmlCtxtDumpNamespace(ctxt, ns);
759 xmlCtxtDumpEntity(xmlDebugCtxtPtr ctxt, xmlEntityPtr ent)
761 xmlCtxtDumpSpaces(ctxt);
764 if (!ctxt->check)
765 fprintf(ctxt->output, "Entity is NULL\n");
768 if (!ctxt->check) {
771 fprintf(ctxt->output, "INTERNAL_GENERAL_ENTITY ");
774 fprintf(ctxt->output, "EXTERNAL_GENERAL_PARSED_ENTITY ");
777 fprintf(ctxt->output, "EXTERNAL_GENERAL_UNPARSED_ENTITY ");
780 fprintf(ctxt->output, "INTERNAL_PARAMETER_ENTITY ");
783 fprintf(ctxt->output, "EXTERNAL_PARAMETER_ENTITY ");
786 fprintf(ctxt->output, "ENTITY_%d ! ", (int) ent->etype);
788 fprintf(ctxt->output, "%s\n", ent->name);
790 xmlCtxtDumpSpaces(ctxt);
791 fprintf(ctxt->output, "ExternalID=%s\n",
795 xmlCtxtDumpSpaces(ctxt);
796 fprintf(ctxt->output, "SystemID=%s\n", (char *) ent->SystemID);
799 xmlCtxtDumpSpaces(ctxt);
800 fprintf(ctxt->output, "URI=%s\n", (char *) ent->URI);
803 xmlCtxtDumpSpaces(ctxt);
804 fprintf(ctxt->output, "content=");
805 xmlCtxtDumpString(ctxt, ent->content);
806 fprintf(ctxt->output, "\n");
820 xmlCtxtDumpAttr(xmlDebugCtxtPtr ctxt, xmlAttrPtr attr)
822 xmlCtxtDumpSpaces(ctxt);
825 if (!ctxt->check)
826 fprintf(ctxt->output, "Attr is NULL");
829 if (!ctxt->check) {
830 fprintf(ctxt->output, "ATTRIBUTE ");
831 xmlCtxtDumpString(ctxt, attr->name);
832 fprintf(ctxt->output, "\n");
834 ctxt->depth++;
835 xmlCtxtDumpNodeList(ctxt, attr->children);
836 ctxt->depth--;
840 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
846 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) attr);
858 xmlCtxtDumpAttrList(xmlDebugCtxtPtr ctxt, xmlAttrPtr attr)
861 xmlCtxtDumpAttr(ctxt, attr);
875 xmlCtxtDumpOneNode(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
878 if (!ctxt->check) {
879 xmlCtxtDumpSpaces(ctxt);
880 fprintf(ctxt->output, "node is NULL\n");
884 ctxt->node = node;
888 if (!ctxt->check) {
889 xmlCtxtDumpSpaces(ctxt);
890 fprintf(ctxt->output, "ELEMENT ");
892 xmlCtxtDumpString(ctxt, node->ns->prefix);
893 fprintf(ctxt->output, ":");
895 xmlCtxtDumpString(ctxt, node->name);
896 fprintf(ctxt->output, "\n");
900 if (!ctxt->check)
901 xmlCtxtDumpSpaces(ctxt);
902 fprintf(ctxt->output, "Error, ATTRIBUTE found here\n");
903 xmlCtxtGenericNodeCheck(ctxt, node);
906 if (!ctxt->check) {
907 xmlCtxtDumpSpaces(ctxt);
909 fprintf(ctxt->output, "TEXT no enc");
911 fprintf(ctxt->output, "TEXT");
912 if (ctxt->options & DUMP_TEXT_TYPE) {
914 fprintf(ctxt->output, " compact\n");
915 else if (xmlDictOwns(ctxt->dict, node->content) == 1)
916 fprintf(ctxt->output, " interned\n");
918 fprintf(ctxt->output, "\n");
920 fprintf(ctxt->output, "\n");
924 if (!ctxt->check) {
925 xmlCtxtDumpSpaces(ctxt);
926 fprintf(ctxt->output, "CDATA_SECTION\n");
930 if (!ctxt->check) {
931 xmlCtxtDumpSpaces(ctxt);
932 fprintf(ctxt->output, "ENTITY_REF(%s)\n",
937 if (!ctxt->check) {
938 xmlCtxtDumpSpaces(ctxt);
939 fprintf(ctxt->output, "ENTITY\n");
943 if (!ctxt->check) {
944 xmlCtxtDumpSpaces(ctxt);
945 fprintf(ctxt->output, "PI %s\n", (char *) node->name);
949 if (!ctxt->check) {
950 xmlCtxtDumpSpaces(ctxt);
951 fprintf(ctxt->output, "COMMENT\n");
956 if (!ctxt->check) {
957 xmlCtxtDumpSpaces(ctxt);
959 fprintf(ctxt->output, "Error, DOCUMENT found here\n");
960 xmlCtxtGenericNodeCheck(ctxt, node);
963 if (!ctxt->check) {
964 xmlCtxtDumpSpaces(ctxt);
965 fprintf(ctxt->output, "DOCUMENT_TYPE\n");
969 if (!ctxt->check) {
970 xmlCtxtDumpSpaces(ctxt);
971 fprintf(ctxt->output, "DOCUMENT_FRAG\n");
975 if (!ctxt->check) {
976 xmlCtxtDumpSpaces(ctxt);
977 fprintf(ctxt->output, "NOTATION\n");
981 xmlCtxtDumpDtdNode(ctxt, (xmlDtdPtr) node);
984 xmlCtxtDumpElemDecl(ctxt, (xmlElementPtr) node);
987 xmlCtxtDumpAttrDecl(ctxt, (xmlAttributePtr) node);
990 xmlCtxtDumpEntityDecl(ctxt, (xmlEntityPtr) node);
993 xmlCtxtDumpNamespace(ctxt, (xmlNsPtr) node);
996 if (!ctxt->check) {
997 xmlCtxtDumpSpaces(ctxt);
998 fprintf(ctxt->output, "INCLUDE START\n");
1002 if (!ctxt->check) {
1003 xmlCtxtDumpSpaces(ctxt);
1004 fprintf(ctxt->output, "INCLUDE END\n");
1008 if (!ctxt->check)
1009 xmlCtxtDumpSpaces(ctxt);
1010 xmlDebugErr2(ctxt, XML_CHECK_UNKNOWN_NODE,
1015 if (!ctxt->check) {
1016 xmlCtxtDumpSpaces(ctxt);
1018 fprintf(ctxt->output, "PBM: doc == NULL !!!\n");
1020 ctxt->depth++;
1022 xmlCtxtDumpNamespaceList(ctxt, node->nsDef);
1024 xmlCtxtDumpAttrList(ctxt, node->properties);
1027 if (!ctxt->check) {
1028 xmlCtxtDumpSpaces(ctxt);
1029 fprintf(ctxt->output, "content=");
1030 xmlCtxtDumpString(ctxt, node->content);
1031 fprintf(ctxt->output, "\n");
1039 xmlCtxtDumpEntity(ctxt, ent);
1041 ctxt->depth--;
1046 xmlCtxtGenericNodeCheck(ctxt, node);
1058 xmlCtxtDumpNode(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
1061 if (!ctxt->check) {
1062 xmlCtxtDumpSpaces(ctxt);
1063 fprintf(ctxt->output, "node is NULL\n");
1067 xmlCtxtDumpOneNode(ctxt, node);
1070 ctxt->depth++;
1071 xmlCtxtDumpNodeList(ctxt, node->children);
1072 ctxt->depth--;
1085 xmlCtxtDumpNodeList(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
1088 xmlCtxtDumpNode(ctxt, node);
1094 xmlCtxtDumpDocHead(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1097 if (!ctxt->check)
1098 fprintf(ctxt->output, "DOCUMENT == NULL !\n");
1101 ctxt->node = (xmlNodePtr) doc;
1105 xmlDebugErr(ctxt, XML_CHECK_FOUND_ELEMENT,
1109 xmlDebugErr(ctxt, XML_CHECK_FOUND_ATTRIBUTE,
1113 xmlDebugErr(ctxt, XML_CHECK_FOUND_TEXT,
1117 xmlDebugErr(ctxt, XML_CHECK_FOUND_CDATA,
1121 xmlDebugErr(ctxt, XML_CHECK_FOUND_ENTITYREF,
1125 xmlDebugErr(ctxt, XML_CHECK_FOUND_ENTITY,
1129 xmlDebugErr(ctxt, XML_CHECK_FOUND_PI,
1133 xmlDebugErr(ctxt, XML_CHECK_FOUND_COMMENT,
1137 if (!ctxt->check)
1138 fprintf(ctxt->output, "DOCUMENT\n");
1141 if (!ctxt->check)
1142 fprintf(ctxt->output, "HTML DOCUMENT\n");
1145 xmlDebugErr(ctxt, XML_CHECK_FOUND_DOCTYPE,
1149 xmlDebugErr(ctxt, XML_CHECK_FOUND_FRAGMENT,
1153 xmlDebugErr(ctxt, XML_CHECK_FOUND_NOTATION,
1157 xmlDebugErr2(ctxt, XML_CHECK_UNKNOWN_NODE,
1170 xmlCtxtDumpDocumentHead(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1173 xmlCtxtDumpDocHead(ctxt, doc);
1174 if (!ctxt->check) {
1176 fprintf(ctxt->output, "name=");
1177 xmlCtxtDumpString(ctxt, BAD_CAST doc->name);
1178 fprintf(ctxt->output, "\n");
1181 fprintf(ctxt->output, "version=");
1182 xmlCtxtDumpString(ctxt, doc->version);
1183 fprintf(ctxt->output, "\n");
1186 fprintf(ctxt->output, "encoding=");
1187 xmlCtxtDumpString(ctxt, doc->encoding);
1188 fprintf(ctxt->output, "\n");
1191 fprintf(ctxt->output, "URL=");
1192 xmlCtxtDumpString(ctxt, doc->URL);
1193 fprintf(ctxt->output, "\n");
1196 fprintf(ctxt->output, "standalone=true\n");
1199 xmlCtxtDumpNamespaceList(ctxt, doc->oldNs);
1210 xmlCtxtDumpDocument(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1213 if (!ctxt->check)
1214 fprintf(ctxt->output, "DOCUMENT == NULL !\n");
1217 xmlCtxtDumpDocumentHead(ctxt, doc);
1221 ctxt->depth++;
1222 xmlCtxtDumpNodeList(ctxt, doc->children);
1223 ctxt->depth--;
1228 xmlCtxtDumpEntityCallback(xmlEntityPtr cur, xmlDebugCtxtPtr ctxt)
1231 if (!ctxt->check)
1232 fprintf(ctxt->output, "Entity is NULL");
1235 if (!ctxt->check) {
1236 fprintf(ctxt->output, "%s : ", (char *) cur->name);
1239 fprintf(ctxt->output, "INTERNAL GENERAL, ");
1242 fprintf(ctxt->output, "EXTERNAL PARSED, ");
1245 fprintf(ctxt->output, "EXTERNAL UNPARSED, ");
1248 fprintf(ctxt->output, "INTERNAL PARAMETER, ");
1251 fprintf(ctxt->output, "EXTERNAL PARAMETER, ");
1254 xmlDebugErr2(ctxt, XML_CHECK_ENTITY_TYPE,
1258 fprintf(ctxt->output, "ID \"%s\"", (char *) cur->ExternalID);
1260 fprintf(ctxt->output, "SYSTEM \"%s\"", (char *) cur->SystemID);
1262 fprintf(ctxt->output, "\n orig \"%s\"", (char *) cur->orig);
1264 fprintf(ctxt->output, "\n content \"%s\"",
1266 fprintf(ctxt->output, "\n");
1278 xmlCtxtDumpEntities(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1281 xmlCtxtDumpDocHead(ctxt, doc);
1286 if (!ctxt->check)
1287 fprintf(ctxt->output, "Entities in internal subset\n");
1289 ctxt);
1291 fprintf(ctxt->output, "No entities in internal subset\n");
1296 if (!ctxt->check)
1297 fprintf(ctxt->output, "Entities in external subset\n");
1299 ctxt);
1300 } else if (!ctxt->check)
1301 fprintf(ctxt->output, "No entities in external subset\n");
1312 xmlCtxtDumpDTD(xmlDebugCtxtPtr ctxt, xmlDtdPtr dtd)
1315 if (!ctxt->check)
1316 fprintf(ctxt->output, "DTD is NULL\n");
1319 xmlCtxtDumpDtdNode(ctxt, dtd);
1321 fprintf(ctxt->output, " DTD is empty\n");
1323 ctxt->depth++;
1324 xmlCtxtDumpNodeList(ctxt, dtd->children);
1325 ctxt->depth--;
1375 xmlDebugCtxt ctxt;
1378 xmlCtxtDumpInitCtxt(&ctxt);
1379 ctxt.output = output;
1380 ctxt.depth = depth;
1381 xmlCtxtDumpAttr(&ctxt, attr);
1382 xmlCtxtDumpCleanCtxt(&ctxt);
1396 xmlDebugCtxt ctxt;
1399 xmlCtxtDumpInitCtxt(&ctxt);
1400 ctxt.output = output;
1401 xmlCtxtDumpEntities(&ctxt, doc);
1402 xmlCtxtDumpCleanCtxt(&ctxt);
1416 xmlDebugCtxt ctxt;
1419 xmlCtxtDumpInitCtxt(&ctxt);
1420 ctxt.output = output;
1421 ctxt.depth = depth;
1422 xmlCtxtDumpAttrList(&ctxt, attr);
1423 xmlCtxtDumpCleanCtxt(&ctxt);
1437 xmlDebugCtxt ctxt;
1440 xmlCtxtDumpInitCtxt(&ctxt);
1441 ctxt.output = output;
1442 ctxt.depth = depth;
1443 xmlCtxtDumpOneNode(&ctxt, node);
1444 xmlCtxtDumpCleanCtxt(&ctxt);
1458 xmlDebugCtxt ctxt;
1462 xmlCtxtDumpInitCtxt(&ctxt);
1463 ctxt.output = output;
1464 ctxt.depth = depth;
1465 xmlCtxtDumpNode(&ctxt, node);
1466 xmlCtxtDumpCleanCtxt(&ctxt);
1480 xmlDebugCtxt ctxt;
1484 xmlCtxtDumpInitCtxt(&ctxt);
1485 ctxt.output = output;
1486 ctxt.depth = depth;
1487 xmlCtxtDumpNodeList(&ctxt, node);
1488 xmlCtxtDumpCleanCtxt(&ctxt);
1501 xmlDebugCtxt ctxt;
1505 xmlCtxtDumpInitCtxt(&ctxt);
1506 ctxt.options |= DUMP_TEXT_TYPE;
1507 ctxt.output = output;
1508 xmlCtxtDumpDocumentHead(&ctxt, doc);
1509 xmlCtxtDumpCleanCtxt(&ctxt);
1522 xmlDebugCtxt ctxt;
1526 xmlCtxtDumpInitCtxt(&ctxt);
1527 ctxt.options |= DUMP_TEXT_TYPE;
1528 ctxt.output = output;
1529 xmlCtxtDumpDocument(&ctxt, doc);
1530 xmlCtxtDumpCleanCtxt(&ctxt);
1543 xmlDebugCtxt ctxt;
1547 xmlCtxtDumpInitCtxt(&ctxt);
1548 ctxt.options |= DUMP_TEXT_TYPE;
1549 ctxt.output = output;
1550 xmlCtxtDumpDTD(&ctxt, dtd);
1551 xmlCtxtDumpCleanCtxt(&ctxt);
1573 xmlDebugCtxt ctxt;
1577 xmlCtxtDumpInitCtxt(&ctxt);
1578 ctxt.output = output;
1579 ctxt.check = 1;
1580 xmlCtxtDumpDocument(&ctxt, doc);
1581 xmlCtxtDumpCleanCtxt(&ctxt);
1582 return(ctxt.errors);
1877 * @ctxt : a non-null shell context
1883 xmlShellPrintNodeCtxt(xmlShellCtxtPtr ctxt,xmlNodePtr node)
1889 if (ctxt == NULL)
1892 fp = ctxt->output;
1919 * @ctxt: a valid shell context
1925 xmlShellPrintXPathResultCtxt(xmlShellCtxtPtr ctxt,xmlXPathObjectPtr list)
1927 if (!ctxt)
1939 xmlShellPrintNodeCtxt(ctxt,
1986 * @ctxt: the shell context
1997 xmlShellList(xmlShellCtxtPtr ctxt,
2002 if (!ctxt)
2005 fprintf(ctxt->output, "NULL\n");
2012 xmlLsOneNode(ctxt->output, node);
2017 xmlLsOneNode(ctxt->output, node);
2021 xmlLsOneNode(ctxt->output, cur);
2029 * @ctxt: the shell context
2040 xmlShellBase(xmlShellCtxtPtr ctxt,
2045 if (!ctxt)
2048 fprintf(ctxt->output, "NULL\n");
2055 fprintf(ctxt->output, " No base found !!!\n");
2057 fprintf(ctxt->output, "%s\n", base);
2066 * @ctxt: the shell context
2077 xmlShellSetBase(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2089 * @ctxt: the shell context
2101 xmlShellRegisterNamespace(xmlShellCtxtPtr ctxt, char *arg,
2120 fprintf(ctxt->output, "setns: prefix=[nsuri] required\n");
2134 if(xmlXPathRegisterNs(ctxt->pctxt, prefix, href) != 0) {
2135 fprintf(ctxt->output,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", prefix, href);
2146 * @ctxt: the shell context
2157 xmlShellRegisterRootNamespaces(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_UNUSED,
2163 (root->nsDef == NULL) || (ctxt == NULL) || (ctxt->pctxt == NULL))
2168 xmlXPathRegisterNs(ctxt->pctxt, BAD_CAST "defaultns", ns->href);
2170 xmlXPathRegisterNs(ctxt->pctxt, ns->prefix, ns->href);
2179 * @ctxt: the shell context
2190 xmlShellGrep(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2193 if (!ctxt)
2210 fprintf(ctxt->output, "%s : ", xmlGetNodePath(node));
2211 xmlShellList(ctxt, NULL, node, NULL);
2216 fprintf(ctxt->output, "%s : ", xmlGetNodePath(node->parent));
2217 xmlShellList(ctxt, NULL, node->parent, NULL);
2257 * @ctxt: the shell context
2268 xmlShellDir(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2272 if (!ctxt)
2275 fprintf(ctxt->output, "NULL\n");
2280 xmlDebugDumpDocumentHead(ctxt->output, (xmlDocPtr) node);
2282 xmlDebugDumpAttr(ctxt->output, (xmlAttrPtr) node, 0);
2284 xmlDebugDumpOneNode(ctxt->output, node, 0);
2291 * @ctxt: the shell context
2302 xmlShellSetContent(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2309 if (!ctxt)
2312 fprintf(ctxt->output, "NULL\n");
2316 fprintf(ctxt->output, "NULL\n");
2329 fprintf(ctxt->output, "failed to parse content\n");
2337 * @ctxt: the shell context
2353 xmlRelaxNGParserCtxtPtr ctxt;
2357 ctxt = xmlRelaxNGNewParserCtxt(schemas);
2358 xmlRelaxNGSetParserErrors(ctxt,
2362 relaxngschemas = xmlRelaxNGParse(ctxt);
2363 xmlRelaxNGFreeParserCtxt(ctxt);
2393 * @ctxt: the shell context
2404 xmlShellCat(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_UNUSED,
2407 if (!ctxt)
2410 fprintf(ctxt->output, "NULL\n");
2413 if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) {
2416 htmlDocDump(ctxt->output, (htmlDocPtr) node);
2418 htmlNodeDumpFile(ctxt->output, ctxt->doc, node);
2421 xmlDocDump(ctxt->output, (xmlDocPtr) node);
2423 xmlElemDump(ctxt->output, ctxt->doc, node);
2427 xmlDocDump(ctxt->output, (xmlDocPtr) node);
2429 xmlElemDump(ctxt->output, ctxt->doc, node);
2431 fprintf(ctxt->output, "\n");
2438 * @ctxt: the shell context
2449 xmlShellLoad(xmlShellCtxtPtr ctxt, char *filename,
2456 if ((ctxt == NULL) || (filename == NULL)) return(-1);
2457 if (ctxt->doc != NULL)
2458 html = (ctxt->doc->type == XML_HTML_DOCUMENT_NODE);
2464 fprintf(ctxt->output, "HTML support not compiled in\n");
2471 if (ctxt->loaded == 1) {
2472 xmlFreeDoc(ctxt->doc);
2474 ctxt->loaded = 1;
2476 xmlXPathFreeContext(ctxt->pctxt);
2478 xmlFree(ctxt->filename);
2479 ctxt->doc = doc;
2480 ctxt->node = (xmlNodePtr) doc;
2482 ctxt->pctxt = xmlXPathNewContext(doc);
2484 ctxt->filename = (char *) xmlCanonicPath((xmlChar *) filename);
2493 * @ctxt: the shell context
2505 xmlShellWrite(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
2522 if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
2530 if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
2536 if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
2552 xmlElemDump(f, ctxt->doc, node);
2561 * @ctxt: the shell context
2572 xmlShellSave(xmlShellCtxtPtr ctxt, char *filename,
2576 if ((ctxt == NULL) || (ctxt->doc == NULL))
2579 filename = ctxt->filename;
2589 switch (ctxt->doc->type) {
2591 if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
2598 if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
2603 if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
2622 * @ctxt: the shell context
2634 xmlShellValidate(xmlShellCtxtPtr ctxt, char *dtd,
2641 if ((ctxt == NULL) || (ctxt->doc == NULL)) return(-1);
2647 res = xmlValidateDocument(&vctxt, ctxt->doc);
2653 res = xmlValidateDtd(&vctxt, ctxt->doc, subset);
2664 * @ctxt: the shell context
2676 xmlShellDu(xmlShellCtxtPtr ctxt,
2683 if (!ctxt)
2692 fprintf(ctxt->output, "/\n");
2695 fprintf(ctxt->output, " ");
2696 fprintf(ctxt->output, "%s\n", node->name);
2746 * @ctxt: the shell context
2759 xmlShellPwd(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED, char *buffer,
2807 xmlShellCtxtPtr ctxt;
2818 ctxt = (xmlShellCtxtPtr) xmlMalloc(sizeof(xmlShellCtxt));
2819 if (ctxt == NULL)
2821 ctxt->loaded = 0;
2822 ctxt->doc = doc;
2823 ctxt->input = input;
2824 ctxt->output = output;
2825 ctxt->filename = (char *) xmlStrdup((xmlChar *) filename);
2826 ctxt->node = (xmlNodePtr) ctxt->doc;
2829 ctxt->pctxt = xmlXPathNewContext(ctxt->doc);
2830 if (ctxt->pctxt == NULL) {
2831 xmlFree(ctxt);
2836 if (ctxt->node == (xmlNodePtr) ctxt->doc)
2838 else if ((ctxt->node != NULL) && (ctxt->node->name))
2839 snprintf(prompt, sizeof(prompt), "%s > ", ctxt->node->name);
2847 cmdline = ctxt->input(prompt);
2895 fprintf(ctxt->output, "\tbase display XML base of the node\n");
2896 fprintf(ctxt->output, "\tsetbase URI change the XML base of the node\n");
2897 fprintf(ctxt->output, "\tbye leave shell\n");
2898 fprintf(ctxt->output, "\tcat [node] display node or current node\n");
2899 fprintf(ctxt->output, "\tcd [path] change directory to path or to root\n");
2900 fprintf(ctxt->output, "\tdir [path] dumps informations about the node (namespace, attributes, content)\n");
2901 fprintf(ctxt->output, "\tdu [path] show the structure of the subtree under path or the current node\n");
2902 fprintf(ctxt->output, "\texit leave shell\n");
2903 fprintf(ctxt->output, "\thelp display this help\n");
2904 fprintf(ctxt->output, "\tfree display memory usage\n");
2905 fprintf(ctxt->output, "\tload [name] load a new document with name\n");
2906 fprintf(ctxt->output, "\tls [path] list contents of path or the current directory\n");
2907 fprintf(ctxt->output, "\tset xml_fragment replace the current node content with the fragment parsed in context\n");
2909 fprintf(ctxt->output, "\txpath expr evaluate the XPath expression in that context and print the result\n");
2910 fprintf(ctxt->output, "\tsetns nsreg register a namespace to a prefix in the XPath evaluation context\n");
2911 fprintf(ctxt->output, "\t format for nsreg is: prefix=[nsuri] (i.e. prefix= unsets a prefix)\n");
2912 fprintf(ctxt->output, "\tsetrootns register all namespace found on the root element\n");
2913 fprintf(ctxt->output, "\t the default namespace if any uses 'defaultns' prefix\n");
2915 fprintf(ctxt->output, "\tpwd display current working directory\n");
2916 fprintf(ctxt->output, "\tquit leave shell\n");
2918 fprintf(ctxt->output, "\tsave [name] save this document to name or the original name\n");
2919 fprintf(ctxt->output, "\twrite [name] write the current node to the filename\n");
2922 fprintf(ctxt->output, "\tvalidate check the document for errors\n");
2925 fprintf(ctxt->output, "\trelaxng rng validate the document agaisnt the Relax-NG schemas\n");
2927 fprintf(ctxt->output, "\tgrep string search for a string in the subtree\n");
2930 xmlShellValidate(ctxt, arg, NULL, NULL);
2933 xmlShellLoad(ctxt, arg, NULL, NULL);
2936 xmlShellRNGValidate(ctxt, arg, NULL, NULL);
2940 xmlShellSave(ctxt, arg, NULL, NULL);
2946 xmlShellWrite(ctxt, arg, NULL, NULL);
2949 xmlShellGrep(ctxt, arg, ctxt->node, NULL);
2952 xmlMemShow(ctxt->output, 0);
2957 xmlMemShow(ctxt->output, len);
2962 if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL))
2963 fprintf(ctxt->output, "%s\n", dir);
2965 xmlShellDu(ctxt, NULL, ctxt->node, NULL);
2967 xmlShellBase(ctxt, NULL, ctxt->node, NULL);
2969 xmlShellSetContent(ctxt, arg, ctxt->node, NULL);
2976 xmlShellRegisterNamespace(ctxt, arg, NULL, NULL);
2981 root = xmlDocGetRootElement(ctxt->doc);
2982 xmlShellRegisterRootNamespaces(ctxt, NULL, root, NULL);
2988 ctxt->pctxt->node = ctxt->node;
2989 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
2990 xmlXPathDebugDumpObject(ctxt->output, list, 0);
2996 xmlShellSetBase(ctxt, arg, ctxt->node, NULL);
3003 xmlShellDir(ctxt, NULL, ctxt->node, NULL);
3005 xmlShellList(ctxt, NULL, ctxt->node, NULL);
3007 ctxt->pctxt->node = ctxt->node;
3009 ctxt->pctxt->node = ctxt->node;
3010 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3030 xmlShellDir(ctxt, NULL,
3034 xmlShellList(ctxt, NULL,
3081 ctxt->pctxt->node = NULL;
3085 ctxt->node = (xmlNodePtr) ctxt->doc;
3088 ctxt->pctxt->node = ctxt->node;
3089 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3102 ctxt->node = list->nodesetval->nodeTab[0];
3103 if ((ctxt->node != NULL) &&
3104 (ctxt->node->type ==
3108 ctxt->node = NULL;
3161 ctxt->pctxt->node = NULL;
3166 xmlShellCat(ctxt, NULL, ctxt->node, NULL);
3168 ctxt->pctxt->node = ctxt->node;
3170 ctxt->pctxt->node = ctxt->node;
3171 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3191 fprintf(ctxt->output, " -------\n");
3192 xmlShellCat(ctxt, NULL,
3239 ctxt->pctxt->node = NULL;
3249 xmlXPathFreeContext(ctxt->pctxt);
3251 if (ctxt->loaded) {
3252 xmlFreeDoc(ctxt->doc);
3254 if (ctxt->filename != NULL)
3255 xmlFree(ctxt->filename);
3256 xmlFree(ctxt);