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--;
1232 xmlCtxtDumpEntityCallback(xmlEntityPtr cur, xmlDebugCtxtPtr ctxt)
1235 if (!ctxt->check)
1236 fprintf(ctxt->output, "Entity is NULL");
1239 if (!ctxt->check) {
1240 fprintf(ctxt->output, "%s : ", (char *) cur->name);
1243 fprintf(ctxt->output, "INTERNAL GENERAL, ");
1246 fprintf(ctxt->output, "EXTERNAL PARSED, ");
1249 fprintf(ctxt->output, "EXTERNAL UNPARSED, ");
1252 fprintf(ctxt->output, "INTERNAL PARAMETER, ");
1255 fprintf(ctxt->output, "EXTERNAL PARAMETER, ");
1258 xmlDebugErr2(ctxt, XML_CHECK_ENTITY_TYPE,
1262 fprintf(ctxt->output, "ID \"%s\"", (char *) cur->ExternalID);
1264 fprintf(ctxt->output, "SYSTEM \"%s\"", (char *) cur->SystemID);
1266 fprintf(ctxt->output, "\n orig \"%s\"", (char *) cur->orig);
1268 fprintf(ctxt->output, "\n content \"%s\"",
1270 fprintf(ctxt->output, "\n");
1282 xmlCtxtDumpEntities(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1285 xmlCtxtDumpDocHead(ctxt, doc);
1290 if (!ctxt->check)
1291 fprintf(ctxt->output, "Entities in internal subset\n");
1293 ctxt);
1295 fprintf(ctxt->output, "No entities in internal subset\n");
1300 if (!ctxt->check)
1301 fprintf(ctxt->output, "Entities in external subset\n");
1303 ctxt);
1304 } else if (!ctxt->check)
1305 fprintf(ctxt->output, "No entities in external subset\n");
1316 xmlCtxtDumpDTD(xmlDebugCtxtPtr ctxt, xmlDtdPtr dtd)
1319 if (!ctxt->check)
1320 fprintf(ctxt->output, "DTD is NULL\n");
1323 xmlCtxtDumpDtdNode(ctxt, dtd);
1325 fprintf(ctxt->output, " DTD is empty\n");
1327 ctxt->depth++;
1328 xmlCtxtDumpNodeList(ctxt, dtd->children);
1329 ctxt->depth--;
1379 xmlDebugCtxt ctxt;
1382 xmlCtxtDumpInitCtxt(&ctxt);
1383 ctxt.output = output;
1384 ctxt.depth = depth;
1385 xmlCtxtDumpAttr(&ctxt, attr);
1386 xmlCtxtDumpCleanCtxt(&ctxt);
1400 xmlDebugCtxt ctxt;
1403 xmlCtxtDumpInitCtxt(&ctxt);
1404 ctxt.output = output;
1405 xmlCtxtDumpEntities(&ctxt, doc);
1406 xmlCtxtDumpCleanCtxt(&ctxt);
1420 xmlDebugCtxt ctxt;
1423 xmlCtxtDumpInitCtxt(&ctxt);
1424 ctxt.output = output;
1425 ctxt.depth = depth;
1426 xmlCtxtDumpAttrList(&ctxt, attr);
1427 xmlCtxtDumpCleanCtxt(&ctxt);
1441 xmlDebugCtxt ctxt;
1444 xmlCtxtDumpInitCtxt(&ctxt);
1445 ctxt.output = output;
1446 ctxt.depth = depth;
1447 xmlCtxtDumpOneNode(&ctxt, node);
1448 xmlCtxtDumpCleanCtxt(&ctxt);
1462 xmlDebugCtxt ctxt;
1466 xmlCtxtDumpInitCtxt(&ctxt);
1467 ctxt.output = output;
1468 ctxt.depth = depth;
1469 xmlCtxtDumpNode(&ctxt, node);
1470 xmlCtxtDumpCleanCtxt(&ctxt);
1484 xmlDebugCtxt ctxt;
1488 xmlCtxtDumpInitCtxt(&ctxt);
1489 ctxt.output = output;
1490 ctxt.depth = depth;
1491 xmlCtxtDumpNodeList(&ctxt, node);
1492 xmlCtxtDumpCleanCtxt(&ctxt);
1505 xmlDebugCtxt ctxt;
1509 xmlCtxtDumpInitCtxt(&ctxt);
1510 ctxt.options |= DUMP_TEXT_TYPE;
1511 ctxt.output = output;
1512 xmlCtxtDumpDocumentHead(&ctxt, doc);
1513 xmlCtxtDumpCleanCtxt(&ctxt);
1526 xmlDebugCtxt ctxt;
1530 xmlCtxtDumpInitCtxt(&ctxt);
1531 ctxt.options |= DUMP_TEXT_TYPE;
1532 ctxt.output = output;
1533 xmlCtxtDumpDocument(&ctxt, doc);
1534 xmlCtxtDumpCleanCtxt(&ctxt);
1547 xmlDebugCtxt ctxt;
1551 xmlCtxtDumpInitCtxt(&ctxt);
1552 ctxt.options |= DUMP_TEXT_TYPE;
1553 ctxt.output = output;
1554 xmlCtxtDumpDTD(&ctxt, dtd);
1555 xmlCtxtDumpCleanCtxt(&ctxt);
1577 xmlDebugCtxt ctxt;
1581 xmlCtxtDumpInitCtxt(&ctxt);
1582 ctxt.output = output;
1583 ctxt.check = 1;
1584 xmlCtxtDumpDocument(&ctxt, doc);
1585 xmlCtxtDumpCleanCtxt(&ctxt);
1586 return(ctxt.errors);
1884 * @ctxt : a non-null shell context
1890 xmlShellPrintNodeCtxt(xmlShellCtxtPtr ctxt,xmlNodePtr node)
1896 if (ctxt == NULL)
1899 fp = ctxt->output;
1926 * @ctxt: a valid shell context
1932 xmlShellPrintXPathResultCtxt(xmlShellCtxtPtr ctxt,xmlXPathObjectPtr list)
1934 if (!ctxt)
1946 xmlShellPrintNodeCtxt(ctxt,
1993 * @ctxt: the shell context
2004 xmlShellList(xmlShellCtxtPtr ctxt,
2009 if (!ctxt)
2012 fprintf(ctxt->output, "NULL\n");
2019 xmlLsOneNode(ctxt->output, node);
2024 xmlLsOneNode(ctxt->output, node);
2028 xmlLsOneNode(ctxt->output, cur);
2036 * @ctxt: the shell context
2047 xmlShellBase(xmlShellCtxtPtr ctxt,
2052 if (!ctxt)
2055 fprintf(ctxt->output, "NULL\n");
2062 fprintf(ctxt->output, " No base found !!!\n");
2064 fprintf(ctxt->output, "%s\n", base);
2073 * @ctxt: the shell context
2084 xmlShellSetBase(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2096 * @ctxt: the shell context
2108 xmlShellRegisterNamespace(xmlShellCtxtPtr ctxt, char *arg,
2127 fprintf(ctxt->output, "setns: prefix=[nsuri] required\n");
2141 if(xmlXPathRegisterNs(ctxt->pctxt, prefix, href) != 0) {
2142 fprintf(ctxt->output,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", prefix, href);
2153 * @ctxt: the shell context
2164 xmlShellRegisterRootNamespaces(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_UNUSED,
2170 (root->nsDef == NULL) || (ctxt == NULL) || (ctxt->pctxt == NULL))
2175 xmlXPathRegisterNs(ctxt->pctxt, BAD_CAST "defaultns", ns->href);
2177 xmlXPathRegisterNs(ctxt->pctxt, ns->prefix, ns->href);
2186 * @ctxt: the shell context
2197 xmlShellGrep(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2200 if (!ctxt)
2217 fprintf(ctxt->output, "%s : ", xmlGetNodePath(node));
2218 xmlShellList(ctxt, NULL, node, NULL);
2223 fprintf(ctxt->output, "%s : ", xmlGetNodePath(node->parent));
2224 xmlShellList(ctxt, NULL, node->parent, NULL);
2264 * @ctxt: the shell context
2275 xmlShellDir(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2279 if (!ctxt)
2282 fprintf(ctxt->output, "NULL\n");
2287 xmlDebugDumpDocumentHead(ctxt->output, (xmlDocPtr) node);
2289 xmlDebugDumpAttr(ctxt->output, (xmlAttrPtr) node, 0);
2291 xmlDebugDumpOneNode(ctxt->output, node, 0);
2298 * @ctxt: the shell context
2309 xmlShellSetContent(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
2316 if (!ctxt)
2319 fprintf(ctxt->output, "NULL\n");
2323 fprintf(ctxt->output, "NULL\n");
2336 fprintf(ctxt->output, "failed to parse content\n");
2344 * @ctxt: the shell context
2360 xmlRelaxNGParserCtxtPtr ctxt;
2364 ctxt = xmlRelaxNGNewParserCtxt(schemas);
2365 xmlRelaxNGSetParserErrors(ctxt,
2369 relaxngschemas = xmlRelaxNGParse(ctxt);
2370 xmlRelaxNGFreeParserCtxt(ctxt);
2400 * @ctxt: the shell context
2411 xmlShellCat(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_UNUSED,
2414 if (!ctxt)
2417 fprintf(ctxt->output, "NULL\n");
2420 if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) {
2423 htmlDocDump(ctxt->output, (htmlDocPtr) node);
2425 htmlNodeDumpFile(ctxt->output, ctxt->doc, node);
2428 xmlDocDump(ctxt->output, (xmlDocPtr) node);
2430 xmlElemDump(ctxt->output, ctxt->doc, node);
2434 xmlDocDump(ctxt->output, (xmlDocPtr) node);
2436 xmlElemDump(ctxt->output, ctxt->doc, node);
2438 fprintf(ctxt->output, "\n");
2445 * @ctxt: the shell context
2456 xmlShellLoad(xmlShellCtxtPtr ctxt, char *filename,
2463 if ((ctxt == NULL) || (filename == NULL)) return(-1);
2464 if (ctxt->doc != NULL)
2465 html = (ctxt->doc->type == XML_HTML_DOCUMENT_NODE);
2471 fprintf(ctxt->output, "HTML support not compiled in\n");
2478 if (ctxt->loaded == 1) {
2479 xmlFreeDoc(ctxt->doc);
2481 ctxt->loaded = 1;
2483 xmlXPathFreeContext(ctxt->pctxt);
2485 xmlFree(ctxt->filename);
2486 ctxt->doc = doc;
2487 ctxt->node = (xmlNodePtr) doc;
2489 ctxt->pctxt = xmlXPathNewContext(doc);
2491 ctxt->filename = (char *) xmlCanonicPath((xmlChar *) filename);
2500 * @ctxt: the shell context
2512 xmlShellWrite(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
2529 if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
2537 if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
2543 if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
2559 xmlElemDump(f, ctxt->doc, node);
2568 * @ctxt: the shell context
2579 xmlShellSave(xmlShellCtxtPtr ctxt, char *filename,
2583 if ((ctxt == NULL) || (ctxt->doc == NULL))
2586 filename = ctxt->filename;
2596 switch (ctxt->doc->type) {
2598 if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
2605 if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
2610 if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
2629 * @ctxt: the shell context
2641 xmlShellValidate(xmlShellCtxtPtr ctxt, char *dtd,
2648 if ((ctxt == NULL) || (ctxt->doc == NULL)) return(-1);
2654 res = xmlValidateDocument(&vctxt, ctxt->doc);
2660 res = xmlValidateDtd(&vctxt, ctxt->doc, subset);
2671 * @ctxt: the shell context
2683 xmlShellDu(xmlShellCtxtPtr ctxt,
2690 if (!ctxt)
2699 fprintf(ctxt->output, "/\n");
2702 fprintf(ctxt->output, " ");
2704 fprintf(ctxt->output, "%s:", node->ns->prefix);
2705 fprintf(ctxt->output, "%s\n", node->name);
2755 * @ctxt: the shell context
2768 xmlShellPwd(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED, char *buffer,
2815 xmlShellCtxtPtr ctxt;
2826 ctxt = (xmlShellCtxtPtr) xmlMalloc(sizeof(xmlShellCtxt));
2827 if (ctxt == NULL)
2829 ctxt->loaded = 0;
2830 ctxt->doc = doc;
2831 ctxt->input = input;
2832 ctxt->output = output;
2833 ctxt->filename = (char *) xmlStrdup((xmlChar *) filename);
2834 ctxt->node = (xmlNodePtr) ctxt->doc;
2837 ctxt->pctxt = xmlXPathNewContext(ctxt->doc);
2838 if (ctxt->pctxt == NULL) {
2839 xmlFree(ctxt);
2844 if (ctxt->node == (xmlNodePtr) ctxt->doc)
2846 else if ((ctxt->node != NULL) && (ctxt->node->name) &&
2847 (ctxt->node->ns) && (ctxt->node->ns->prefix))
2849 (ctxt->node->ns->prefix), ctxt->node->name);
2850 else if ((ctxt->node != NULL) && (ctxt->node->name))
2851 snprintf(prompt, sizeof(prompt), "%s > ", ctxt->node->name);
2859 cmdline = ctxt->input(prompt);
2903 fprintf(ctxt->output, "\tbase display XML base of the node\n");
2904 fprintf(ctxt->output, "\tsetbase URI change the XML base of the node\n");
2905 fprintf(ctxt->output, "\tbye leave shell\n");
2906 fprintf(ctxt->output, "\tcat [node] display node or current node\n");
2907 fprintf(ctxt->output, "\tcd [path] change directory to path or to root\n");
2908 fprintf(ctxt->output, "\tdir [path] dumps informations about the node (namespace, attributes, content)\n");
2909 fprintf(ctxt->output, "\tdu [path] show the structure of the subtree under path or the current node\n");
2910 fprintf(ctxt->output, "\texit leave shell\n");
2911 fprintf(ctxt->output, "\thelp display this help\n");
2912 fprintf(ctxt->output, "\tfree display memory usage\n");
2913 fprintf(ctxt->output, "\tload [name] load a new document with name\n");
2914 fprintf(ctxt->output, "\tls [path] list contents of path or the current directory\n");
2915 fprintf(ctxt->output, "\tset xml_fragment replace the current node content with the fragment parsed in context\n");
2917 fprintf(ctxt->output, "\txpath expr evaluate the XPath expression in that context and print the result\n");
2918 fprintf(ctxt->output, "\tsetns nsreg register a namespace to a prefix in the XPath evaluation context\n");
2919 fprintf(ctxt->output, "\t format for nsreg is: prefix=[nsuri] (i.e. prefix= unsets a prefix)\n");
2920 fprintf(ctxt->output, "\tsetrootns register all namespace found on the root element\n");
2921 fprintf(ctxt->output, "\t the default namespace if any uses 'defaultns' prefix\n");
2923 fprintf(ctxt->output, "\tpwd display current working directory\n");
2924 fprintf(ctxt->output, "\twhereis display absolute path of [path] or current working directory\n");
2925 fprintf(ctxt->output, "\tquit leave shell\n");
2927 fprintf(ctxt->output, "\tsave [name] save this document to name or the original name\n");
2928 fprintf(ctxt->output, "\twrite [name] write the current node to the filename\n");
2931 fprintf(ctxt->output, "\tvalidate check the document for errors\n");
2934 fprintf(ctxt->output, "\trelaxng rng validate the document agaisnt the Relax-NG schemas\n");
2936 fprintf(ctxt->output, "\tgrep string search for a string in the subtree\n");
2939 xmlShellValidate(ctxt, arg, NULL, NULL);
2942 xmlShellLoad(ctxt, arg, NULL, NULL);
2945 xmlShellRNGValidate(ctxt, arg, NULL, NULL);
2949 xmlShellSave(ctxt, arg, NULL, NULL);
2955 xmlShellWrite(ctxt, arg, ctxt->node, NULL);
2958 xmlShellGrep(ctxt, arg, ctxt->node, NULL);
2961 xmlMemShow(ctxt->output, 0);
2966 xmlMemShow(ctxt->output, len);
2971 if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL))
2972 fprintf(ctxt->output, "%s\n", dir);
2975 xmlShellDu(ctxt, NULL, ctxt->node, NULL);
2977 ctxt->pctxt->node = ctxt->node;
2979 ctxt->pctxt->node = ctxt->node;
2980 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
2999 xmlShellDu(ctxt, NULL,
3045 ctxt->pctxt->node = NULL;
3048 xmlShellBase(ctxt, NULL, ctxt->node, NULL);
3050 xmlShellSetContent(ctxt, arg, ctxt->node, NULL);
3057 xmlShellRegisterNamespace(ctxt, arg, NULL, NULL);
3062 root = xmlDocGetRootElement(ctxt->doc);
3063 xmlShellRegisterRootNamespaces(ctxt, NULL, root, NULL);
3069 ctxt->pctxt->node = ctxt->node;
3070 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3071 xmlXPathDebugDumpObject(ctxt->output, list, 0);
3077 xmlShellSetBase(ctxt, arg, ctxt->node, NULL);
3084 xmlShellDir(ctxt, NULL, ctxt->node, NULL);
3086 xmlShellList(ctxt, NULL, ctxt->node, NULL);
3088 ctxt->pctxt->node = ctxt->node;
3090 ctxt->pctxt->node = ctxt->node;
3091 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3111 xmlShellDir(ctxt, NULL,
3115 xmlShellList(ctxt, NULL,
3162 ctxt->pctxt->node = NULL;
3168 if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL))
3169 fprintf(ctxt->output, "%s\n", dir);
3171 ctxt->pctxt->node = ctxt->node;
3173 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3192 if (!xmlShellPwd(ctxt, dir, list->nodesetval->
3194 fprintf(ctxt->output, "%s\n", dir);
3239 ctxt->pctxt->node = NULL;
3243 ctxt->node = (xmlNodePtr) ctxt->doc;
3248 ctxt->pctxt->node = ctxt->node;
3252 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3265 ctxt->node = list->nodesetval->nodeTab[0];
3266 if ((ctxt->node != NULL) &&
3267 (ctxt->node->type ==
3271 ctxt->node = NULL;
3324 ctxt->pctxt->node = NULL;
3329 xmlShellCat(ctxt, NULL, ctxt->node, NULL);
3331 ctxt->pctxt->node = ctxt->node;
3333 ctxt->pctxt->node = ctxt->node;
3334 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
3354 fprintf(ctxt->output, " -------\n");
3355 xmlShellCat(ctxt, NULL,
3402 ctxt->pctxt->node = NULL;
3413 xmlXPathFreeContext(ctxt->pctxt);
3415 if (ctxt->loaded) {
3416 xmlFreeDoc(ctxt->doc);
3418 if (ctxt->filename != NULL)
3419 xmlFree(ctxt->filename);
3420 xmlFree(ctxt);