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);
360 xmlCtxtCheckString(ctxt, (const xmlChar *) node->content);
365 xmlCtxtCheckName(ctxt, node->name);
372 if ((ctxt->dict != NULL) &&
373 (node->name == xmlDictLookup(ctxt->dict, BAD_CAST "nbktext",
377 xmlDebugErr3(ctxt, XML_CHECK_WRONG_NAME,
384 xmlDebugErr3(ctxt, XML_CHECK_WRONG_NAME,
389 xmlCtxtCheckName(ctxt, node->name);
394 xmlDebugErr3(ctxt, XML_CHECK_NAME_NOT_NULL,
420 xmlCtxtDumpString(xmlDebugCtxtPtr ctxt, const xmlChar * str)
424 if (ctxt->check) {
429 fprintf(ctxt->output, "(NULL)");
436 fputc(' ', ctxt->output);
438 fprintf(ctxt->output, "#%X", str[i]);
440 fputc(str[i], ctxt->output);
441 fprintf(ctxt->output, "...");
445 xmlCtxtDumpDtdNode(xmlDebugCtxtPtr ctxt, xmlDtdPtr dtd)
447 xmlCtxtDumpSpaces(ctxt);
450 if (!ctxt->check)
451 fprintf(ctxt->output, "DTD node is NULL\n");
456 xmlDebugErr(ctxt, XML_CHECK_NOT_DTD,
460 if (!ctxt->check) {
462 fprintf(ctxt->output, "DTD(%s)", (char *) dtd->name);
464 fprintf(ctxt->output, "DTD");
466 fprintf(ctxt->output, ", PUBLIC %s", (char *) dtd->ExternalID);
468 fprintf(ctxt->output, ", SYSTEM %s", (char *) dtd->SystemID);
469 fprintf(ctxt->output, "\n");
474 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) dtd);
478 xmlCtxtDumpAttrDecl(xmlDebugCtxtPtr ctxt, xmlAttributePtr attr)
480 xmlCtxtDumpSpaces(ctxt);
483 if (!ctxt->check)
484 fprintf(ctxt->output, "Attribute declaration is NULL\n");
488 xmlDebugErr(ctxt, XML_CHECK_NOT_ATTR_DECL,
493 if (!ctxt->check)
494 fprintf(ctxt->output, "ATTRDECL(%s)", (char *) attr->name);
496 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
499 if (!ctxt->check)
500 fprintf(ctxt->output, " for %s", (char *) attr->elem);
502 xmlDebugErr(ctxt, XML_CHECK_NO_ELEM,
504 if (!ctxt->check) {
507 fprintf(ctxt->output, " CDATA");
510 fprintf(ctxt->output, " ID");
513 fprintf(ctxt->output, " IDREF");
516 fprintf(ctxt->output, " IDREFS");
519 fprintf(ctxt->output, " ENTITY");
522 fprintf(ctxt->output, " ENTITIES");
525 fprintf(ctxt->output, " NMTOKEN");
528 fprintf(ctxt->output, " NMTOKENS");
531 fprintf(ctxt->output, " ENUMERATION");
534 fprintf(ctxt->output, " NOTATION ");
543 fprintf(ctxt->output, "|%s", (char *) cur->name);
545 fprintf(ctxt->output, " (%s", (char *) cur->name);
551 fprintf(ctxt->output, ")");
553 fprintf(ctxt->output, "...)");
559 fprintf(ctxt->output, " REQUIRED");
562 fprintf(ctxt->output, " IMPLIED");
565 fprintf(ctxt->output, " FIXED");
569 fprintf(ctxt->output, "\"");
570 xmlCtxtDumpString(ctxt, attr->defaultValue);
571 fprintf(ctxt->output, "\"");
573 fprintf(ctxt->output, "\n");
579 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) attr);
583 xmlCtxtDumpElemDecl(xmlDebugCtxtPtr ctxt, xmlElementPtr elem)
585 xmlCtxtDumpSpaces(ctxt);
588 if (!ctxt->check)
589 fprintf(ctxt->output, "Element declaration is NULL\n");
593 xmlDebugErr(ctxt, XML_CHECK_NOT_ELEM_DECL,
598 if (!ctxt->check) {
599 fprintf(ctxt->output, "ELEMDECL(");
600 xmlCtxtDumpString(ctxt, elem->name);
601 fprintf(ctxt->output, ")");
604 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
606 if (!ctxt->check) {
609 fprintf(ctxt->output, ", UNDEFINED");
612 fprintf(ctxt->output, ", EMPTY");
615 fprintf(ctxt->output, ", ANY");
618 fprintf(ctxt->output, ", MIXED ");
621 fprintf(ctxt->output, ", MIXED ");
630 fprintf(ctxt->output, "%s", buf);
632 fprintf(ctxt->output, "\n");
638 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) elem);
642 xmlCtxtDumpEntityDecl(xmlDebugCtxtPtr ctxt, xmlEntityPtr ent)
644 xmlCtxtDumpSpaces(ctxt);
647 if (!ctxt->check)
648 fprintf(ctxt->output, "Entity declaration is NULL\n");
652 xmlDebugErr(ctxt, XML_CHECK_NOT_ENTITY_DECL,
657 if (!ctxt->check) {
658 fprintf(ctxt->output, "ENTITYDECL(");
659 xmlCtxtDumpString(ctxt, ent->name);
660 fprintf(ctxt->output, ")");
663 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
665 if (!ctxt->check) {
668 fprintf(ctxt->output, ", internal\n");
671 fprintf(ctxt->output, ", external parsed\n");
674 fprintf(ctxt->output, ", unparsed\n");
677 fprintf(ctxt->output, ", parameter\n");
680 fprintf(ctxt->output, ", external parameter\n");
683 fprintf(ctxt->output, ", predefined\n");
687 xmlCtxtDumpSpaces(ctxt);
688 fprintf(ctxt->output, " ExternalID=%s\n",
692 xmlCtxtDumpSpaces(ctxt);
693 fprintf(ctxt->output, " SystemID=%s\n",
697 xmlCtxtDumpSpaces(ctxt);
698 fprintf(ctxt->output, " URI=%s\n", (char *) ent->URI);
701 xmlCtxtDumpSpaces(ctxt);
702 fprintf(ctxt->output, " content=");
703 xmlCtxtDumpString(ctxt, ent->content);
704 fprintf(ctxt->output, "\n");
711 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) ent);
715 xmlCtxtDumpNamespace(xmlDebugCtxtPtr ctxt, xmlNsPtr ns)
717 xmlCtxtDumpSpaces(ctxt);
720 if (!ctxt->check)
721 fprintf(ctxt->output, "namespace node is NULL\n");
725 xmlDebugErr(ctxt, XML_CHECK_NOT_NS_DECL,
731 xmlDebugErr3(ctxt, XML_CHECK_NO_HREF,
735 xmlDebugErr(ctxt, XML_CHECK_NO_HREF,
738 if (!ctxt->check) {
740 fprintf(ctxt->output, "namespace %s href=",
743 fprintf(ctxt->output, "default namespace href=");
745 xmlCtxtDumpString(ctxt, ns->href);
746 fprintf(ctxt->output, "\n");
752 xmlCtxtDumpNamespaceList(xmlDebugCtxtPtr ctxt, xmlNsPtr ns)
755 xmlCtxtDumpNamespace(ctxt, ns);
761 xmlCtxtDumpEntity(xmlDebugCtxtPtr ctxt, xmlEntityPtr ent)
763 xmlCtxtDumpSpaces(ctxt);
766 if (!ctxt->check)
767 fprintf(ctxt->output, "Entity is NULL\n");
770 if (!ctxt->check) {
773 fprintf(ctxt->output, "INTERNAL_GENERAL_ENTITY ");
776 fprintf(ctxt->output, "EXTERNAL_GENERAL_PARSED_ENTITY ");
779 fprintf(ctxt->output, "EXTERNAL_GENERAL_UNPARSED_ENTITY ");
782 fprintf(ctxt->output, "INTERNAL_PARAMETER_ENTITY ");
785 fprintf(ctxt->output, "EXTERNAL_PARAMETER_ENTITY ");
788 fprintf(ctxt->output, "ENTITY_%d ! ", (int) ent->etype);
790 fprintf(ctxt->output, "%s\n", ent->name);
792 xmlCtxtDumpSpaces(ctxt);
793 fprintf(ctxt->output, "ExternalID=%s\n",
797 xmlCtxtDumpSpaces(ctxt);
798 fprintf(ctxt->output, "SystemID=%s\n", (char *) ent->SystemID);
801 xmlCtxtDumpSpaces(ctxt);
802 fprintf(ctxt->output, "URI=%s\n", (char *) ent->URI);
805 xmlCtxtDumpSpaces(ctxt);
806 fprintf(ctxt->output, "content=");
807 xmlCtxtDumpString(ctxt, ent->content);
808 fprintf(ctxt->output, "\n");
822 xmlCtxtDumpAttr(xmlDebugCtxtPtr ctxt, xmlAttrPtr attr)
824 xmlCtxtDumpSpaces(ctxt);
827 if (!ctxt->check)
828 fprintf(ctxt->output, "Attr is NULL");
831 if (!ctxt->check) {
832 fprintf(ctxt->output, "ATTRIBUTE ");
833 xmlCtxtDumpString(ctxt, attr->name);
834 fprintf(ctxt->output, "\n");
836 ctxt->depth++;
837 xmlCtxtDumpNodeList(ctxt, attr->children);
838 ctxt->depth--;
842 xmlDebugErr(ctxt, XML_CHECK_NO_NAME,
848 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) attr);
860 xmlCtxtDumpAttrList(xmlDebugCtxtPtr ctxt, xmlAttrPtr attr)
863 xmlCtxtDumpAttr(ctxt, attr);
877 xmlCtxtDumpOneNode(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
880 if (!ctxt->check) {
881 xmlCtxtDumpSpaces(ctxt);
882 fprintf(ctxt->output, "node is NULL\n");
886 ctxt->node = node;
890 if (!ctxt->check) {
891 xmlCtxtDumpSpaces(ctxt);
892 fprintf(ctxt->output, "ELEMENT ");
894 xmlCtxtDumpString(ctxt, node->ns->prefix);
895 fprintf(ctxt->output, ":");
897 xmlCtxtDumpString(ctxt, node->name);
898 fprintf(ctxt->output, "\n");
902 if (!ctxt->check)
903 xmlCtxtDumpSpaces(ctxt);
904 fprintf(ctxt->output, "Error, ATTRIBUTE found here\n");
905 xmlCtxtGenericNodeCheck(ctxt, node);
908 if (!ctxt->check) {
909 xmlCtxtDumpSpaces(ctxt);
911 fprintf(ctxt->output, "TEXT no enc");
913 fprintf(ctxt->output, "TEXT");
914 if (ctxt->options & DUMP_TEXT_TYPE) {
916 fprintf(ctxt->output, " compact\n");
917 else if (xmlDictOwns(ctxt->dict, node->content) == 1)
918 fprintf(ctxt->output, " interned\n");
920 fprintf(ctxt->output, "\n");
922 fprintf(ctxt->output, "\n");
926 if (!ctxt->check) {
927 xmlCtxtDumpSpaces(ctxt);
928 fprintf(ctxt->output, "CDATA_SECTION\n");
932 if (!ctxt->check) {
933 xmlCtxtDumpSpaces(ctxt);
934 fprintf(ctxt->output, "ENTITY_REF(%s)\n",
939 if (!ctxt->check) {
940 xmlCtxtDumpSpaces(ctxt);
941 fprintf(ctxt->output, "ENTITY\n");
945 if (!ctxt->check) {
946 xmlCtxtDumpSpaces(ctxt);
947 fprintf(ctxt->output, "PI %s\n", (char *) node->name);
951 if (!ctxt->check) {
952 xmlCtxtDumpSpaces(ctxt);
953 fprintf(ctxt->output, "COMMENT\n");
958 if (!ctxt->check) {
959 xmlCtxtDumpSpaces(ctxt);
961 fprintf(ctxt->output, "Error, DOCUMENT found here\n");
962 xmlCtxtGenericNodeCheck(ctxt, node);
965 if (!ctxt->check) {
966 xmlCtxtDumpSpaces(ctxt);
967 fprintf(ctxt->output, "DOCUMENT_TYPE\n");
971 if (!ctxt->check) {
972 xmlCtxtDumpSpaces(ctxt);
973 fprintf(ctxt->output, "DOCUMENT_FRAG\n");
977 if (!ctxt->check) {
978 xmlCtxtDumpSpaces(ctxt);
979 fprintf(ctxt->output, "NOTATION\n");
983 xmlCtxtDumpDtdNode(ctxt, (xmlDtdPtr) node);
986 xmlCtxtDumpElemDecl(ctxt, (xmlElementPtr) node);
989 xmlCtxtDumpAttrDecl(ctxt, (xmlAttributePtr) node);
992 xmlCtxtDumpEntityDecl(ctxt, (xmlEntityPtr) node);
995 xmlCtxtDumpNamespace(ctxt, (xmlNsPtr) node);
998 if (!ctxt->check) {
999 xmlCtxtDumpSpaces(ctxt);
1000 fprintf(ctxt->output, "INCLUDE START\n");
1004 if (!ctxt->check) {
1005 xmlCtxtDumpSpaces(ctxt);
1006 fprintf(ctxt->output, "INCLUDE END\n");
1010 if (!ctxt->check)
1011 xmlCtxtDumpSpaces(ctxt);
1012 xmlDebugErr2(ctxt, XML_CHECK_UNKNOWN_NODE,
1017 if (!ctxt->check) {
1018 xmlCtxtDumpSpaces(ctxt);
1020 fprintf(ctxt->output, "PBM: doc == NULL !!!\n");
1022 ctxt->depth++;
1024 xmlCtxtDumpNamespaceList(ctxt, node->nsDef);
1026 xmlCtxtDumpAttrList(ctxt, node->properties);
1029 if (!ctxt->check) {
1030 xmlCtxtDumpSpaces(ctxt);
1031 fprintf(ctxt->output, "content=");
1032 xmlCtxtDumpString(ctxt, node->content);
1033 fprintf(ctxt->output, "\n");
1041 xmlCtxtDumpEntity(ctxt, ent);
1043 ctxt->depth--;
1048 xmlCtxtGenericNodeCheck(ctxt, node);
1060 xmlCtxtDumpNode(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
1063 if (!ctxt->check) {
1064 xmlCtxtDumpSpaces(ctxt);
1065 fprintf(ctxt->output, "node is NULL\n");
1069 xmlCtxtDumpOneNode(ctxt, node);
1072 ctxt->depth++;
1073 xmlCtxtDumpNodeList(ctxt, node->children);
1074 ctxt->depth--;
1087 xmlCtxtDumpNodeList(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
1090 xmlCtxtDumpNode(ctxt, node);
1096 xmlCtxtDumpDocHead(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1099 if (!ctxt->check)
1100 fprintf(ctxt->output, "DOCUMENT == NULL !\n");
1103 ctxt->node = (xmlNodePtr) doc;
1107 xmlDebugErr(ctxt, XML_CHECK_FOUND_ELEMENT,
1111 xmlDebugErr(ctxt, XML_CHECK_FOUND_ATTRIBUTE,
1115 xmlDebugErr(ctxt, XML_CHECK_FOUND_TEXT,
1119 xmlDebugErr(ctxt, XML_CHECK_FOUND_CDATA,
1123 xmlDebugErr(ctxt, XML_CHECK_FOUND_ENTITYREF,
1127 xmlDebugErr(ctxt, XML_CHECK_FOUND_ENTITY,
1131 xmlDebugErr(ctxt, XML_CHECK_FOUND_PI,
1135 xmlDebugErr(ctxt, XML_CHECK_FOUND_COMMENT,
1139 if (!ctxt->check)
1140 fprintf(ctxt->output, "DOCUMENT\n");
1143 if (!ctxt->check)
1144 fprintf(ctxt->output, "HTML DOCUMENT\n");
1147 xmlDebugErr(ctxt, XML_CHECK_FOUND_DOCTYPE,
1151 xmlDebugErr(ctxt, XML_CHECK_FOUND_FRAGMENT,
1155 xmlDebugErr(ctxt, XML_CHECK_FOUND_NOTATION,
1159 xmlDebugErr2(ctxt, XML_CHECK_UNKNOWN_NODE,
1172 xmlCtxtDumpDocumentHead(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1175 xmlCtxtDumpDocHead(ctxt, doc);
1176 if (!ctxt->check) {
1178 fprintf(ctxt->output, "name=");
1179 xmlCtxtDumpString(ctxt, BAD_CAST doc->name);
1180 fprintf(ctxt->output, "\n");
1183 fprintf(ctxt->output, "version=");
1184 xmlCtxtDumpString(ctxt, doc->version);
1185 fprintf(ctxt->output, "\n");
1188 fprintf(ctxt->output, "encoding=");
1189 xmlCtxtDumpString(ctxt, doc->encoding);
1190 fprintf(ctxt->output, "\n");
1193 fprintf(ctxt->output, "URL=");
1194 xmlCtxtDumpString(ctxt, doc->URL);
1195 fprintf(ctxt->output, "\n");
1198 fprintf(ctxt->output, "standalone=true\n");
1201 xmlCtxtDumpNamespaceList(ctxt, doc->oldNs);
1212 xmlCtxtDumpDocument(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1215 if (!ctxt->check)
1216 fprintf(ctxt->output, "DOCUMENT == NULL !\n");
1219 xmlCtxtDumpDocumentHead(ctxt, doc);
1223 ctxt->depth++;
1224 xmlCtxtDumpNodeList(ctxt, doc->children);
1225 ctxt->depth--;
1230 xmlCtxtDumpEntityCallback(xmlEntityPtr cur, xmlDebugCtxtPtr ctxt)
1233 if (!ctxt->check)
1234 fprintf(ctxt->output, "Entity is NULL");
1237 if (!ctxt->check) {
1238 fprintf(ctxt->output, "%s : ", (char *) cur->name);
1241 fprintf(ctxt->output, "INTERNAL GENERAL, ");
1244 fprintf(ctxt->output, "EXTERNAL PARSED, ");
1247 fprintf(ctxt->output, "EXTERNAL UNPARSED, ");
1250 fprintf(ctxt->output, "INTERNAL PARAMETER, ");
1253 fprintf(ctxt->output, "EXTERNAL PARAMETER, ");
1256 xmlDebugErr2(ctxt, XML_CHECK_ENTITY_TYPE,
1260 fprintf(ctxt->output, "ID \"%s\"", (char *) cur->ExternalID);
1262 fprintf(ctxt->output, "SYSTEM \"%s\"", (char *) cur->SystemID);
1264 fprintf(ctxt->output, "\n orig \"%s\"", (char *) cur->orig);
1266 fprintf(ctxt->output, "\n content \"%s\"",
1268 fprintf(ctxt->output, "\n");
1280 xmlCtxtDumpEntities(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1283 xmlCtxtDumpDocHead(ctxt, doc);
1288 if (!ctxt->check)
1289 fprintf(ctxt->output, "Entities in internal subset\n");
1291 ctxt);
1293 fprintf(ctxt->output, "No entities in internal subset\n");
1298 if (!ctxt->check)
1299 fprintf(ctxt->output, "Entities in external subset\n");
1301 ctxt);
1302 } else if (!ctxt->check)
1303 fprintf(ctxt->output, "No entities in external subset\n");
1314 xmlCtxtDumpDTD(xmlDebugCtxtPtr ctxt, xmlDtdPtr dtd)
1317 if (!ctxt->check)
1318 fprintf(ctxt->output, "DTD is NULL\n");
1321 xmlCtxtDumpDtdNode(ctxt, dtd);
1323 fprintf(ctxt->output, " DTD is empty\n");
1325 ctxt->depth++;
1326 xmlCtxtDumpNodeList(ctxt, dtd->children);
1327 ctxt->depth--;
1377 xmlDebugCtxt ctxt;
1380 xmlCtxtDumpInitCtxt(&ctxt);
1381 ctxt.output = output;
1382 ctxt.depth = depth;
1383 xmlCtxtDumpAttr(&ctxt, attr);
1384 xmlCtxtDumpCleanCtxt(&ctxt);
1398 xmlDebugCtxt ctxt;
1401 xmlCtxtDumpInitCtxt(&ctxt);
1402 ctxt.output = output;
1403 xmlCtxtDumpEntities(&ctxt, doc);
1404 xmlCtxtDumpCleanCtxt(&ctxt);
1418 xmlDebugCtxt ctxt;
1421 xmlCtxtDumpInitCtxt(&ctxt);
1422 ctxt.output = output;
1423 ctxt.depth = depth;
1424 xmlCtxtDumpAttrList(&ctxt, attr);
1425 xmlCtxtDumpCleanCtxt(&ctxt);
1439 xmlDebugCtxt ctxt;
1442 xmlCtxtDumpInitCtxt(&ctxt);
1443 ctxt.output = output;
1444 ctxt.depth = depth;
1445 xmlCtxtDumpOneNode(&ctxt, node);
1446 xmlCtxtDumpCleanCtxt(&ctxt);
1460 xmlDebugCtxt ctxt;
1464 xmlCtxtDumpInitCtxt(&ctxt);
1465 ctxt.output = output;
1466 ctxt.depth = depth;
1467 xmlCtxtDumpNode(&ctxt, node);
1468 xmlCtxtDumpCleanCtxt(&ctxt);
1482 xmlDebugCtxt ctxt;
1486 xmlCtxtDumpInitCtxt(&ctxt);
1487 ctxt.output = output;
1488 ctxt.depth = depth;
1489 xmlCtxtDumpNodeList(&ctxt, node);
1490 xmlCtxtDumpCleanCtxt(&ctxt);
1503 xmlDebugCtxt ctxt;
1507 xmlCtxtDumpInitCtxt(&ctxt);
1508 ctxt.options |= DUMP_TEXT_TYPE;
1509 ctxt.output = output;
1510 xmlCtxtDumpDocumentHead(&ctxt, doc);
1511 xmlCtxtDumpCleanCtxt(&ctxt);
1524 xmlDebugCtxt ctxt;
1528 xmlCtxtDumpInitCtxt(&ctxt);
1529 ctxt.options |= DUMP_TEXT_TYPE;
1530 ctxt.output = output;
1531 xmlCtxtDumpDocument(&ctxt, doc);
1532 xmlCtxtDumpCleanCtxt(&ctxt);
1545 xmlDebugCtxt ctxt;
1549 xmlCtxtDumpInitCtxt(&ctxt);
1550 ctxt.options |= DUMP_TEXT_TYPE;
1551 ctxt.output = output;
1552 xmlCtxtDumpDTD(&ctxt, dtd);
1553 xmlCtxtDumpCleanCtxt(&ctxt);
1575 xmlDebugCtxt ctxt;
1579 xmlCtxtDumpInitCtxt(&ctxt);
1580 ctxt.output = output;
1581 ctxt.check = 1;
1582 xmlCtxtDumpDocument(&ctxt, doc);
1583 xmlCtxtDumpCleanCtxt(&ctxt);
1584 return(ctxt.errors);
1879 * @ctxt : a non-null shell context
1885 xmlShellPrintNodeCtxt(xmlShellCtxtPtr ctxt,xmlNodePtr node)
1891 if (ctxt == NULL)
1894 fp = ctxt->output;
1921 * @ctxt: a valid shell context
1927 xmlShellPrintXPathResultCtxt(xmlShellCtxtPtr ctxt,xmlXPathObjectPtr list)
1929 if (!ctxt)
1941 xmlShellPrintNodeCtxt(ctxt,
1988 * @ctxt: the shell context
1999 xmlShellList(xmlShellCtxtPtr ctxt,
2004 if (!ctxt)
2007 fprintf(ctxt->output, "NULL\n");
2014 xmlLsOneNode(ctxt->output, node);
2019 xmlLsOneNode(ctxt->output, node);
2023 xmlLsOneNode(ctxt->output, cur);
2031 * @ctxt: the shell context
2042 xmlShellBase(xmlShellCtxtPtr ctxt,
2047 if (!ctxt)
2050 fprintf(ctxt->output, "NULL\n");
2057 fprintf(ctxt->output, " No base found !!!\n");
2059 fprintf(ctxt->output, "%s\n", base);
2068 * @ctxt: the shell context
2079 xmlShellSetBase(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2091 * @ctxt: the shell context
2103 xmlShellRegisterNamespace(xmlShellCtxtPtr ctxt, char *arg,
2122 fprintf(ctxt->output, "setns: prefix=[nsuri] required\n");
2136 if(xmlXPathRegisterNs(ctxt->pctxt, prefix, href) != 0) {
2137 fprintf(ctxt->output,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", prefix, href);
2148 * @ctxt: the shell context
2159 xmlShellRegisterRootNamespaces(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_UNUSED,
2165 (root->nsDef == NULL) || (ctxt == NULL) || (ctxt->pctxt == NULL))
2170 xmlXPathRegisterNs(ctxt->pctxt, BAD_CAST "defaultns", ns->href);
2172 xmlXPathRegisterNs(ctxt->pctxt, ns->prefix, ns->href);
2181 * @ctxt: the shell context
2192 xmlShellGrep(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2195 if (!ctxt)
2212 fprintf(ctxt->output, "%s : ", xmlGetNodePath(node));
2213 xmlShellList(ctxt, NULL, node, NULL);
2218 fprintf(ctxt->output, "%s : ", xmlGetNodePath(node->parent));
2219 xmlShellList(ctxt, NULL, node->parent, NULL);
2259 * @ctxt: the shell context
2270 xmlShellDir(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2274 if (!ctxt)
2277 fprintf(ctxt->output, "NULL\n");
2282 xmlDebugDumpDocumentHead(ctxt->output, (xmlDocPtr) node);
2284 xmlDebugDumpAttr(ctxt->output, (xmlAttrPtr) node, 0);
2286 xmlDebugDumpOneNode(ctxt->output, node, 0);
2293 * @ctxt: the shell context
2304 xmlShellSetContent(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2311 if (!ctxt)
2314 fprintf(ctxt->output, "NULL\n");
2318 fprintf(ctxt->output, "NULL\n");
2331 fprintf(ctxt->output, "failed to parse content\n");
2339 * @ctxt: the shell context
2355 xmlRelaxNGParserCtxtPtr ctxt;
2359 ctxt = xmlRelaxNGNewParserCtxt(schemas);
2360 xmlRelaxNGSetParserErrors(ctxt,
2364 relaxngschemas = xmlRelaxNGParse(ctxt);
2365 xmlRelaxNGFreeParserCtxt(ctxt);
2395 * @ctxt: the shell context
2406 xmlShellCat(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_UNUSED,
2409 if (!ctxt)
2412 fprintf(ctxt->output, "NULL\n");
2415 if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) {
2418 htmlDocDump(ctxt->output, (htmlDocPtr) node);
2420 htmlNodeDumpFile(ctxt->output, ctxt->doc, node);
2423 xmlDocDump(ctxt->output, (xmlDocPtr) node);
2425 xmlElemDump(ctxt->output, ctxt->doc, node);
2429 xmlDocDump(ctxt->output, (xmlDocPtr) node);
2431 xmlElemDump(ctxt->output, ctxt->doc, node);
2433 fprintf(ctxt->output, "\n");
2440 * @ctxt: the shell context
2451 xmlShellLoad(xmlShellCtxtPtr ctxt, char *filename,
2458 if ((ctxt == NULL) || (filename == NULL)) return(-1);
2459 if (ctxt->doc != NULL)
2460 html = (ctxt->doc->type == XML_HTML_DOCUMENT_NODE);
2466 fprintf(ctxt->output, "HTML support not compiled in\n");
2473 if (ctxt->loaded == 1) {
2474 xmlFreeDoc(ctxt->doc);
2476 ctxt->loaded = 1;
2478 xmlXPathFreeContext(ctxt->pctxt);
2480 xmlFree(ctxt->filename);
2481 ctxt->doc = doc;
2482 ctxt->node = (xmlNodePtr) doc;
2484 ctxt->pctxt = xmlXPathNewContext(doc);
2486 ctxt->filename = (char *) xmlCanonicPath((xmlChar *) filename);
2495 * @ctxt: the shell context
2507 xmlShellWrite(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
2524 if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
2532 if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
2538 if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
2554 xmlElemDump(f, ctxt->doc, node);
2563 * @ctxt: the shell context
2574 xmlShellSave(xmlShellCtxtPtr ctxt, char *filename,
2578 if ((ctxt == NULL) || (ctxt->doc == NULL))
2581 filename = ctxt->filename;
2591 switch (ctxt->doc->type) {
2593 if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
2600 if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
2605 if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
2624 * @ctxt: the shell context
2636 xmlShellValidate(xmlShellCtxtPtr ctxt, char *dtd,
2643 if ((ctxt == NULL) || (ctxt->doc == NULL)) return(-1);
2649 res = xmlValidateDocument(&vctxt, ctxt->doc);
2655 res = xmlValidateDtd(&vctxt, ctxt->doc, subset);
2666 * @ctxt: the shell context
2678 xmlShellDu(xmlShellCtxtPtr ctxt,
2685 if (!ctxt)
2694 fprintf(ctxt->output, "/\n");
2697 fprintf(ctxt->output, " ");
2698 fprintf(ctxt->output, "%s\n", node->name);
2748 * @ctxt: the shell context
2761 xmlShellPwd(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED, char *buffer,
2808 xmlShellCtxtPtr ctxt;
2819 ctxt = (xmlShellCtxtPtr) xmlMalloc(sizeof(xmlShellCtxt));
2820 if (ctxt == NULL)
2822 ctxt->loaded = 0;
2823 ctxt->doc = doc;
2824 ctxt->input = input;
2825 ctxt->output = output;
2826 ctxt->filename = (char *) xmlStrdup((xmlChar *) filename);
2827 ctxt->node = (xmlNodePtr) ctxt->doc;
2830 ctxt->pctxt = xmlXPathNewContext(ctxt->doc);
2831 if (ctxt->pctxt == NULL) {
2832 xmlFree(ctxt);
2837 if (ctxt->node == (xmlNodePtr) ctxt->doc)
2839 else if ((ctxt->node != NULL) && (ctxt->node->name))
2840 snprintf(prompt, sizeof(prompt), "%s > ", ctxt->node->name);
2848 cmdline = ctxt->input(prompt);
2892 fprintf(ctxt->output, "\tbase display XML base of the node\n");
2893 fprintf(ctxt->output, "\tsetbase URI change the XML base of the node\n");
2894 fprintf(ctxt->output, "\tbye leave shell\n");
2895 fprintf(ctxt->output, "\tcat [node] display node or current node\n");
2896 fprintf(ctxt->output, "\tcd [path] change directory to path or to root\n");
2897 fprintf(ctxt->output, "\tdir [path] dumps informations about the node (namespace, attributes, content)\n");
2898 fprintf(ctxt->output, "\tdu [path] show the structure of the subtree under path or the current node\n");
2899 fprintf(ctxt->output, "\texit leave shell\n");
2900 fprintf(ctxt->output, "\thelp display this help\n");
2901 fprintf(ctxt->output, "\tfree display memory usage\n");
2902 fprintf(ctxt->output, "\tload [name] load a new document with name\n");
2903 fprintf(ctxt->output, "\tls [path] list contents of path or the current directory\n");
2904 fprintf(ctxt->output, "\tset xml_fragment replace the current node content with the fragment parsed in context\n");
2906 fprintf(ctxt->output, "\txpath expr evaluate the XPath expression in that context and print the result\n");
2907 fprintf(ctxt->output, "\tsetns nsreg register a namespace to a prefix in the XPath evaluation context\n");
2908 fprintf(ctxt->output, "\t format for nsreg is: prefix=[nsuri] (i.e. prefix= unsets a prefix)\n");
2909 fprintf(ctxt->output, "\tsetrootns register all namespace found on the root element\n");
2910 fprintf(ctxt->output, "\t the default namespace if any uses 'defaultns' prefix\n");
2912 fprintf(ctxt->output, "\tpwd display current working directory\n");
2913 fprintf(ctxt->output, "\tquit leave shell\n");
2915 fprintf(ctxt->output, "\tsave [name] save this document to name or the original name\n");
2916 fprintf(ctxt->output, "\twrite [name] write the current node to the filename\n");
2919 fprintf(ctxt->output, "\tvalidate check the document for errors\n");
2922 fprintf(ctxt->output, "\trelaxng rng validate the document agaisnt the Relax-NG schemas\n");
2924 fprintf(ctxt->output, "\tgrep string search for a string in the subtree\n");
2927 xmlShellValidate(ctxt, arg, NULL, NULL);
2930 xmlShellLoad(ctxt, arg, NULL, NULL);
2933 xmlShellRNGValidate(ctxt, arg, NULL, NULL);
2937 xmlShellSave(ctxt, arg, NULL, NULL);
2943 xmlShellWrite(ctxt, arg, NULL, NULL);
2946 xmlShellGrep(ctxt, arg, ctxt->node, NULL);
2949 xmlMemShow(ctxt->output, 0);
2954 xmlMemShow(ctxt->output, len);
2959 if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL))
2960 fprintf(ctxt->output, "%s\n", dir);
2962 xmlShellDu(ctxt, NULL, ctxt->node, NULL);
2964 xmlShellBase(ctxt, NULL, ctxt->node, NULL);
2966 xmlShellSetContent(ctxt, arg, ctxt->node, NULL);
2973 xmlShellRegisterNamespace(ctxt, arg, NULL, NULL);
2978 root = xmlDocGetRootElement(ctxt->doc);
2979 xmlShellRegisterRootNamespaces(ctxt, NULL, root, NULL);
2985 ctxt->pctxt->node = ctxt->node;
2986 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
2987 xmlXPathDebugDumpObject(ctxt->output, list, 0);
2993 xmlShellSetBase(ctxt, arg, ctxt->node, NULL);
3000 xmlShellDir(ctxt, NULL, ctxt->node, NULL);
3002 xmlShellList(ctxt, NULL, ctxt->node, NULL);
3004 ctxt->pctxt->node = ctxt->node;
3006 ctxt->pctxt->node = ctxt->node;
3007 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3027 xmlShellDir(ctxt, NULL,
3031 xmlShellList(ctxt, NULL,
3078 ctxt->pctxt->node = NULL;
3082 ctxt->node = (xmlNodePtr) ctxt->doc;
3085 ctxt->pctxt->node = ctxt->node;
3086 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3099 ctxt->node = list->nodesetval->nodeTab[0];
3100 if ((ctxt->node != NULL) &&
3101 (ctxt->node->type ==
3105 ctxt->node = NULL;
3158 ctxt->pctxt->node = NULL;
3163 xmlShellCat(ctxt, NULL, ctxt->node, NULL);
3165 ctxt->pctxt->node = ctxt->node;
3167 ctxt->pctxt->node = ctxt->node;
3168 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3188 fprintf(ctxt->output, " -------\n");
3189 xmlShellCat(ctxt, NULL,
3236 ctxt->pctxt->node = NULL;
3247 xmlXPathFreeContext(ctxt->pctxt);
3249 if (ctxt->loaded) {
3250 xmlFreeDoc(ctxt->doc);
3252 if (ctxt->filename != NULL)
3253 xmlFree(ctxt->filename);
3254 xmlFree(ctxt);