12#ifdef LIBXML_DEBUG_ENABLED
27#ifdef LIBXML_SCHEMAS_ENABLED
33#define DUMP_TEXT_TYPE 1
35typedef struct _xmlDebugCtxt xmlDebugCtxt;
36typedef xmlDebugCtxt *xmlDebugCtxtPtr;
50static void xmlCtxtDumpNodeList(xmlDebugCtxtPtr ctxt, xmlNodePtr
node);
53xmlCtxtDumpInitCtxt(xmlDebugCtxtPtr ctxt)
66 for (
i = 0;
i < 100;
i++)
89xmlNsCheckScope(xmlNodePtr
node, xmlNsPtr
ns)
96 if ((
node->type != XML_ELEMENT_NODE) &&
97 (
node->type != XML_ATTRIBUTE_NODE) &&
98 (
node->type != XML_DOCUMENT_NODE) &&
99 (
node->type != XML_TEXT_NODE) &&
100 (
node->type != XML_HTML_DOCUMENT_NODE) &&
101 (
node->type != XML_XINCLUDE_START))
105 ((
node->type == XML_ELEMENT_NODE) ||
106 (
node->type == XML_ATTRIBUTE_NODE) ||
107 (
node->type == XML_TEXT_NODE) ||
108 (
node->type == XML_XINCLUDE_START))) {
109 if ((
node->type == XML_ELEMENT_NODE) ||
110 (
node->type == XML_XINCLUDE_START)) {
124 ((
node->type == XML_DOCUMENT_NODE) ||
125 (
node->type == XML_HTML_DOCUMENT_NODE))) {
126 xmlNsPtr oldNs = ((xmlDocPtr)
node)->oldNs;
134xmlCtxtDumpSpaces(xmlDebugCtxtPtr ctxt)
138 if ((ctxt->output !=
NULL) && (ctxt->depth > 0)) {
139 if (ctxt->depth < 50)
140 fprintf(ctxt->output,
"%s", &ctxt->shift[100 - 2 * ctxt->depth]);
142 fprintf(ctxt->output,
"%s", ctxt->shift);
154xmlDebugErr(xmlDebugCtxtPtr ctxt,
int error,
const char *
msg)
193xmlCtxtNsCheckScope(xmlDebugCtxtPtr ctxt, xmlNodePtr
node, xmlNsPtr
ns)
201 "Reference to default namespace not in scope\n");
204 "Reference to namespace '%s' not in scope\n",
210 "Reference to default namespace not on ancestor\n");
213 "Reference to namespace '%s' not on ancestor\n",
226xmlCtxtCheckString(xmlDebugCtxtPtr ctxt,
const xmlChar *
str)
232 "String is not UTF-8 %s", (
const char *)
str);
246xmlCtxtCheckName(xmlDebugCtxtPtr ctxt,
const xmlChar *
name)
253#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
254 if (xmlValidateName(
name, 0)) {
256 "Name is not an NCName '%s'", (
const char *)
name);
259 if ((ctxt->dict !=
NULL) &&
261 ((ctxt->doc ==
NULL) ||
264 "Name is not from the document dictionary '%s'",
265 (
const char *)
name);
271xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr
node) {
279 "Node has no parent\n");
282 "Node has no doc\n");
286 if ((dict ==
NULL) && (ctxt->nodict == 0)) {
289 if (doc->type == XML_DOCUMENT_NODE)
291 "Document has no dictionary\n");
295 if (ctxt->doc ==
NULL)
298 if (ctxt->dict ==
NULL) {
305 "Node doc differs from parent's one\n");
307 if (
node->type == XML_ATTRIBUTE_NODE) {
309 (
node != (xmlNodePtr)
node->parent->properties))
311 "Attr has no prev and not first of attr list\n");
315 "Node has no prev and not first of parent list\n");
319 "Node prev->next : back link wrong\n");
322 if ((
node->parent !=
NULL) && (
node->type != XML_ATTRIBUTE_NODE) &&
324 (
node->parent->type == XML_ELEMENT_NODE))
326 "Node has no next and not last of parent list\n");
330 "Node next->prev : forward link wrong\n");
333 "Node next->prev : forward link wrong\n");
335 if (
node->type == XML_ELEMENT_NODE) {
340 xmlCtxtNsCheckScope(ctxt,
node,
ns);
344 xmlCtxtNsCheckScope(ctxt,
node,
node->ns);
345 }
else if (
node->type == XML_ATTRIBUTE_NODE) {
347 xmlCtxtNsCheckScope(ctxt,
node,
node->ns);
350 if ((
node->type != XML_ELEMENT_NODE) &&
351 (
node->type != XML_ATTRIBUTE_NODE) &&
352 (
node->type != XML_ELEMENT_DECL) &&
353 (
node->type != XML_ATTRIBUTE_DECL) &&
354 (
node->type != XML_DTD_NODE) &&
355 (
node->type != XML_HTML_DOCUMENT_NODE) &&
356 (
node->type != XML_DOCUMENT_NODE)) {
358 xmlCtxtCheckString(ctxt, (
const xmlChar *)
node->content);
360 switch (
node->type) {
361 case XML_ELEMENT_NODE:
362 case XML_ATTRIBUTE_NODE:
363 xmlCtxtCheckName(ctxt,
node->name);
370 if ((ctxt->dict !=
NULL) &&
376 "Text node has wrong name '%s'",
377 (
const char *)
node->name);
379 case XML_COMMENT_NODE:
383 "Comment node has wrong name '%s'",
384 (
const char *)
node->name);
387 xmlCtxtCheckName(ctxt,
node->name);
389 case XML_CDATA_SECTION_NODE:
393 "CData section has non NULL name '%s'",
394 (
const char *)
node->name);
396 case XML_ENTITY_REF_NODE:
397 case XML_ENTITY_NODE:
398 case XML_DOCUMENT_TYPE_NODE:
399 case XML_DOCUMENT_FRAG_NODE:
400 case XML_NOTATION_NODE:
402 case XML_ELEMENT_DECL:
403 case XML_ATTRIBUTE_DECL:
404 case XML_ENTITY_DECL:
405 case XML_NAMESPACE_DECL:
406 case XML_XINCLUDE_START:
407 case XML_XINCLUDE_END:
408 case XML_DOCUMENT_NODE:
409 case XML_HTML_DOCUMENT_NODE:
415xmlCtxtDumpString(xmlDebugCtxtPtr ctxt,
const xmlChar *
str)
424 fprintf(ctxt->output,
"(NULL)");
427 for (
i = 0;
i < 40;
i++)
431 fputc(
' ', ctxt->output);
432 else if (
str[
i] >= 0x80)
440xmlCtxtDumpDtdNode(xmlDebugCtxtPtr ctxt, xmlDtdPtr dtd)
442 xmlCtxtDumpSpaces(ctxt);
446 fprintf(ctxt->output,
"DTD node is NULL\n");
450 if (dtd->type != XML_DTD_NODE) {
452 "Node is not a DTD");
456 if (dtd->name !=
NULL)
457 fprintf(ctxt->output,
"DTD(%s)", (
char *) dtd->name);
460 if (dtd->ExternalID !=
NULL)
461 fprintf(ctxt->output,
", PUBLIC %s", (
char *) dtd->ExternalID);
462 if (dtd->SystemID !=
NULL)
463 fprintf(ctxt->output,
", SYSTEM %s", (
char *) dtd->SystemID);
469 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) dtd);
473xmlCtxtDumpAttrDecl(xmlDebugCtxtPtr ctxt, xmlAttributePtr
attr)
475 xmlCtxtDumpSpaces(ctxt);
479 fprintf(ctxt->output,
"Attribute declaration is NULL\n");
482 if (
attr->type != XML_ATTRIBUTE_DECL) {
484 "Node is not an attribute declaration");
492 "Node attribute declaration has no name");
495 fprintf(ctxt->output,
" for %s", (
char *)
attr->elem);
498 "Node attribute declaration has no element name");
500 switch (
attr->atype) {
501 case XML_ATTRIBUTE_CDATA:
502 fprintf(ctxt->output,
" CDATA");
504 case XML_ATTRIBUTE_ID:
507 case XML_ATTRIBUTE_IDREF:
508 fprintf(ctxt->output,
" IDREF");
510 case XML_ATTRIBUTE_IDREFS:
511 fprintf(ctxt->output,
" IDREFS");
513 case XML_ATTRIBUTE_ENTITY:
514 fprintf(ctxt->output,
" ENTITY");
516 case XML_ATTRIBUTE_ENTITIES:
517 fprintf(ctxt->output,
" ENTITIES");
519 case XML_ATTRIBUTE_NMTOKEN:
520 fprintf(ctxt->output,
" NMTOKEN");
522 case XML_ATTRIBUTE_NMTOKENS:
523 fprintf(ctxt->output,
" NMTOKENS");
525 case XML_ATTRIBUTE_ENUMERATION:
526 fprintf(ctxt->output,
" ENUMERATION");
528 case XML_ATTRIBUTE_NOTATION:
529 fprintf(ctxt->output,
" NOTATION ");
534 xmlEnumerationPtr
cur =
attr->tree;
536 for (indx = 0; indx < 5; indx++) {
538 fprintf(ctxt->output,
"|%s", (
char *)
cur->name);
540 fprintf(ctxt->output,
" (%s", (
char *)
cur->name);
551 case XML_ATTRIBUTE_NONE:
553 case XML_ATTRIBUTE_REQUIRED:
554 fprintf(ctxt->output,
" REQUIRED");
556 case XML_ATTRIBUTE_IMPLIED:
557 fprintf(ctxt->output,
" IMPLIED");
559 case XML_ATTRIBUTE_FIXED:
560 fprintf(ctxt->output,
" FIXED");
565 xmlCtxtDumpString(ctxt,
attr->defaultValue);
574 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr)
attr);
578xmlCtxtDumpElemDecl(xmlDebugCtxtPtr ctxt, xmlElementPtr
elem)
580 xmlCtxtDumpSpaces(ctxt);
584 fprintf(ctxt->output,
"Element declaration is NULL\n");
587 if (
elem->type != XML_ELEMENT_DECL) {
589 "Node is not an element declaration");
594 fprintf(ctxt->output,
"ELEMDECL(");
595 xmlCtxtDumpString(ctxt,
elem->name);
600 "Element declaration has no name");
602 switch (
elem->etype) {
603 case XML_ELEMENT_TYPE_UNDEFINED:
604 fprintf(ctxt->output,
", UNDEFINED");
606 case XML_ELEMENT_TYPE_EMPTY:
607 fprintf(ctxt->output,
", EMPTY");
609 case XML_ELEMENT_TYPE_ANY:
610 fprintf(ctxt->output,
", ANY");
612 case XML_ELEMENT_TYPE_MIXED:
613 fprintf(ctxt->output,
", MIXED ");
615 case XML_ELEMENT_TYPE_ELEMENT:
616 fprintf(ctxt->output,
", MIXED ");
619 if ((
elem->type != XML_ELEMENT_NODE) && (
elem->content !=
NULL)) {
633 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr)
elem);
637xmlCtxtDumpEntityDecl(xmlDebugCtxtPtr ctxt, xmlEntityPtr ent)
639 xmlCtxtDumpSpaces(ctxt);
643 fprintf(ctxt->output,
"Entity declaration is NULL\n");
646 if (ent->type != XML_ENTITY_DECL) {
648 "Node is not an entity declaration");
651 if (ent->name !=
NULL) {
653 fprintf(ctxt->output,
"ENTITYDECL(");
654 xmlCtxtDumpString(ctxt, ent->name);
659 "Entity declaration has no name");
661 switch (ent->etype) {
663 fprintf(ctxt->output,
", internal\n");
666 fprintf(ctxt->output,
", external parsed\n");
669 fprintf(ctxt->output,
", unparsed\n");
672 fprintf(ctxt->output,
", parameter\n");
675 fprintf(ctxt->output,
", external parameter\n");
678 fprintf(ctxt->output,
", predefined\n");
681 if (ent->ExternalID) {
682 xmlCtxtDumpSpaces(ctxt);
683 fprintf(ctxt->output,
" ExternalID=%s\n",
684 (
char *) ent->ExternalID);
687 xmlCtxtDumpSpaces(ctxt);
688 fprintf(ctxt->output,
" SystemID=%s\n",
689 (
char *) ent->SystemID);
691 if (ent->URI !=
NULL) {
692 xmlCtxtDumpSpaces(ctxt);
693 fprintf(ctxt->output,
" URI=%s\n", (
char *) ent->URI);
696 xmlCtxtDumpSpaces(ctxt);
697 fprintf(ctxt->output,
" content=");
698 xmlCtxtDumpString(ctxt, ent->content);
706 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr) ent);
710xmlCtxtDumpNamespace(xmlDebugCtxtPtr ctxt, xmlNsPtr
ns)
712 xmlCtxtDumpSpaces(ctxt);
716 fprintf(ctxt->output,
"namespace node is NULL\n");
719 if (
ns->type != XML_NAMESPACE_DECL) {
721 "Node is not a namespace declaration");
727 "Incomplete namespace %s href=NULL\n",
731 "Incomplete default namespace href=NULL\n");
735 fprintf(ctxt->output,
"namespace %s href=",
738 fprintf(ctxt->output,
"default namespace href=");
740 xmlCtxtDumpString(ctxt,
ns->href);
747xmlCtxtDumpNamespaceList(xmlDebugCtxtPtr ctxt, xmlNsPtr
ns)
750 xmlCtxtDumpNamespace(ctxt,
ns);
756xmlCtxtDumpEntity(xmlDebugCtxtPtr ctxt, xmlEntityPtr ent)
758 xmlCtxtDumpSpaces(ctxt);
762 fprintf(ctxt->output,
"Entity is NULL\n");
766 switch (ent->etype) {
768 fprintf(ctxt->output,
"INTERNAL_GENERAL_ENTITY ");
771 fprintf(ctxt->output,
"EXTERNAL_GENERAL_PARSED_ENTITY ");
774 fprintf(ctxt->output,
"EXTERNAL_GENERAL_UNPARSED_ENTITY ");
777 fprintf(ctxt->output,
"INTERNAL_PARAMETER_ENTITY ");
780 fprintf(ctxt->output,
"EXTERNAL_PARAMETER_ENTITY ");
783 fprintf(ctxt->output,
"ENTITY_%d ! ", (
int) ent->etype);
785 fprintf(ctxt->output,
"%s\n", ent->name);
786 if (ent->ExternalID) {
787 xmlCtxtDumpSpaces(ctxt);
788 fprintf(ctxt->output,
"ExternalID=%s\n",
789 (
char *) ent->ExternalID);
792 xmlCtxtDumpSpaces(ctxt);
793 fprintf(ctxt->output,
"SystemID=%s\n", (
char *) ent->SystemID);
796 xmlCtxtDumpSpaces(ctxt);
797 fprintf(ctxt->output,
"URI=%s\n", (
char *) ent->URI);
800 xmlCtxtDumpSpaces(ctxt);
801 fprintf(ctxt->output,
"content=");
802 xmlCtxtDumpString(ctxt, ent->content);
817xmlCtxtDumpAttr(xmlDebugCtxtPtr ctxt, xmlAttrPtr
attr)
819 xmlCtxtDumpSpaces(ctxt);
823 fprintf(ctxt->output,
"Attr is NULL");
827 fprintf(ctxt->output,
"ATTRIBUTE ");
828 xmlCtxtDumpString(ctxt,
attr->
name);
832 xmlCtxtDumpNodeList(ctxt,
attr->children);
838 "Attribute has no name");
843 xmlCtxtGenericNodeCheck(ctxt, (xmlNodePtr)
attr);
855xmlCtxtDumpAttrList(xmlDebugCtxtPtr ctxt, xmlAttrPtr
attr)
858 xmlCtxtDumpAttr(ctxt,
attr);
872xmlCtxtDumpOneNode(xmlDebugCtxtPtr ctxt, xmlNodePtr
node)
876 xmlCtxtDumpSpaces(ctxt);
877 fprintf(ctxt->output,
"node is NULL\n");
883 switch (
node->type) {
884 case XML_ELEMENT_NODE:
886 xmlCtxtDumpSpaces(ctxt);
887 fprintf(ctxt->output,
"ELEMENT ");
889 xmlCtxtDumpString(ctxt,
node->ns->prefix);
892 xmlCtxtDumpString(ctxt,
node->name);
896 case XML_ATTRIBUTE_NODE:
898 xmlCtxtDumpSpaces(ctxt);
899 fprintf(ctxt->output,
"Error, ATTRIBUTE found here\n");
900 xmlCtxtGenericNodeCheck(ctxt,
node);
904 xmlCtxtDumpSpaces(ctxt);
906 fprintf(ctxt->output,
"TEXT no enc");
909 if (ctxt->options & DUMP_TEXT_TYPE) {
911 fprintf(ctxt->output,
" compact\n");
913 fprintf(ctxt->output,
" interned\n");
920 case XML_CDATA_SECTION_NODE:
922 xmlCtxtDumpSpaces(ctxt);
923 fprintf(ctxt->output,
"CDATA_SECTION\n");
926 case XML_ENTITY_REF_NODE:
928 xmlCtxtDumpSpaces(ctxt);
929 fprintf(ctxt->output,
"ENTITY_REF(%s)\n",
930 (
char *)
node->name);
933 case XML_ENTITY_NODE:
935 xmlCtxtDumpSpaces(ctxt);
936 fprintf(ctxt->output,
"ENTITY\n");
941 xmlCtxtDumpSpaces(ctxt);
942 fprintf(ctxt->output,
"PI %s\n", (
char *)
node->name);
945 case XML_COMMENT_NODE:
947 xmlCtxtDumpSpaces(ctxt);
948 fprintf(ctxt->output,
"COMMENT\n");
951 case XML_DOCUMENT_NODE:
952 case XML_HTML_DOCUMENT_NODE:
954 xmlCtxtDumpSpaces(ctxt);
956 fprintf(ctxt->output,
"Error, DOCUMENT found here\n");
957 xmlCtxtGenericNodeCheck(ctxt,
node);
959 case XML_DOCUMENT_TYPE_NODE:
961 xmlCtxtDumpSpaces(ctxt);
962 fprintf(ctxt->output,
"DOCUMENT_TYPE\n");
965 case XML_DOCUMENT_FRAG_NODE:
967 xmlCtxtDumpSpaces(ctxt);
968 fprintf(ctxt->output,
"DOCUMENT_FRAG\n");
971 case XML_NOTATION_NODE:
973 xmlCtxtDumpSpaces(ctxt);
974 fprintf(ctxt->output,
"NOTATION\n");
978 xmlCtxtDumpDtdNode(ctxt, (xmlDtdPtr)
node);
980 case XML_ELEMENT_DECL:
981 xmlCtxtDumpElemDecl(ctxt, (xmlElementPtr)
node);
983 case XML_ATTRIBUTE_DECL:
984 xmlCtxtDumpAttrDecl(ctxt, (xmlAttributePtr)
node);
986 case XML_ENTITY_DECL:
987 xmlCtxtDumpEntityDecl(ctxt, (xmlEntityPtr)
node);
989 case XML_NAMESPACE_DECL:
990 xmlCtxtDumpNamespace(ctxt, (xmlNsPtr)
node);
992 case XML_XINCLUDE_START:
994 xmlCtxtDumpSpaces(ctxt);
995 fprintf(ctxt->output,
"INCLUDE START\n");
998 case XML_XINCLUDE_END:
1000 xmlCtxtDumpSpaces(ctxt);
1001 fprintf(ctxt->output,
"INCLUDE END\n");
1006 xmlCtxtDumpSpaces(ctxt);
1008 "Unknown node type %d\n",
node->type);
1013 xmlCtxtDumpSpaces(ctxt);
1015 fprintf(ctxt->output,
"PBM: doc == NULL !!!\n");
1018 if ((
node->type == XML_ELEMENT_NODE) && (
node->nsDef !=
NULL))
1019 xmlCtxtDumpNamespaceList(ctxt,
node->nsDef);
1020 if ((
node->type == XML_ELEMENT_NODE) && (
node->properties !=
NULL))
1021 xmlCtxtDumpAttrList(ctxt,
node->properties);
1022 if (
node->type != XML_ENTITY_REF_NODE) {
1023 if ((
node->type != XML_ELEMENT_NODE) && (
node->content !=
NULL)) {
1025 xmlCtxtDumpSpaces(ctxt);
1026 fprintf(ctxt->output,
"content=");
1027 xmlCtxtDumpString(ctxt,
node->content);
1036 xmlCtxtDumpEntity(ctxt, ent);
1043 xmlCtxtGenericNodeCheck(ctxt,
node);
1055xmlCtxtDumpNode(xmlDebugCtxtPtr ctxt, xmlNodePtr
node)
1059 xmlCtxtDumpSpaces(ctxt);
1060 fprintf(ctxt->output,
"node is NULL\n");
1064 xmlCtxtDumpOneNode(ctxt,
node);
1065 if ((
node->type != XML_NAMESPACE_DECL) &&
1066 (
node->children !=
NULL) && (
node->type != XML_ENTITY_REF_NODE)) {
1068 xmlCtxtDumpNodeList(ctxt,
node->children);
1082xmlCtxtDumpNodeList(xmlDebugCtxtPtr ctxt, xmlNodePtr
node)
1085 xmlCtxtDumpNode(ctxt,
node);
1091xmlCtxtDumpDocHead(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1095 fprintf(ctxt->output,
"DOCUMENT == NULL !\n");
1098 ctxt->node = (xmlNodePtr) doc;
1100 switch (doc->type) {
1101 case XML_ELEMENT_NODE:
1103 "Misplaced ELEMENT node\n");
1105 case XML_ATTRIBUTE_NODE:
1107 "Misplaced ATTRIBUTE node\n");
1111 "Misplaced TEXT node\n");
1113 case XML_CDATA_SECTION_NODE:
1115 "Misplaced CDATA node\n");
1117 case XML_ENTITY_REF_NODE:
1119 "Misplaced ENTITYREF node\n");
1121 case XML_ENTITY_NODE:
1123 "Misplaced ENTITY node\n");
1127 "Misplaced PI node\n");
1129 case XML_COMMENT_NODE:
1131 "Misplaced COMMENT node\n");
1133 case XML_DOCUMENT_NODE:
1135 fprintf(ctxt->output,
"DOCUMENT\n");
1137 case XML_HTML_DOCUMENT_NODE:
1139 fprintf(ctxt->output,
"HTML DOCUMENT\n");
1141 case XML_DOCUMENT_TYPE_NODE:
1143 "Misplaced DOCTYPE node\n");
1145 case XML_DOCUMENT_FRAG_NODE:
1147 "Misplaced FRAGMENT node\n");
1149 case XML_NOTATION_NODE:
1151 "Misplaced NOTATION node\n");
1155 "Unknown node type %d\n", doc->type);
1167xmlCtxtDumpDocumentHead(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1169 if (doc ==
NULL)
return;
1170 xmlCtxtDumpDocHead(ctxt, doc);
1172 if (doc->name !=
NULL) {
1173 fprintf(ctxt->output,
"name=");
1177 if (doc->version !=
NULL) {
1178 fprintf(ctxt->output,
"version=");
1179 xmlCtxtDumpString(ctxt, doc->version);
1182 if (doc->encoding !=
NULL) {
1183 fprintf(ctxt->output,
"encoding=");
1184 xmlCtxtDumpString(ctxt, doc->encoding);
1187 if (doc->URL !=
NULL) {
1188 fprintf(ctxt->output,
"URL=");
1189 xmlCtxtDumpString(ctxt, doc->URL);
1192 if (doc->standalone)
1193 fprintf(ctxt->output,
"standalone=true\n");
1195 if (doc->oldNs !=
NULL)
1196 xmlCtxtDumpNamespaceList(ctxt, doc->oldNs);
1207xmlCtxtDumpDocument(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1211 fprintf(ctxt->output,
"DOCUMENT == NULL !\n");
1214 xmlCtxtDumpDocumentHead(ctxt, doc);
1215 if (((doc->type == XML_DOCUMENT_NODE) ||
1216 (doc->type == XML_HTML_DOCUMENT_NODE))
1217 && (doc->children !=
NULL)) {
1219 xmlCtxtDumpNodeList(ctxt, doc->children);
1225xmlCtxtDumpEntityCallback(
void *payload,
void *
data,
1228 xmlEntityPtr
cur = (xmlEntityPtr) payload;
1229 xmlDebugCtxtPtr ctxt = (xmlDebugCtxtPtr)
data;
1232 fprintf(ctxt->output,
"Entity is NULL");
1236 fprintf(ctxt->output,
"%s : ", (
char *)
cur->name);
1237 switch (
cur->etype) {
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, ");
1255 "Unknown entity type %d\n",
cur->etype);
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);
1263 if ((
cur->type != XML_ELEMENT_NODE) && (
cur->content !=
NULL))
1264 fprintf(ctxt->output,
"\n content \"%s\"",
1265 (
char *)
cur->content);
1278xmlCtxtDumpEntities(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
1280 if (doc ==
NULL)
return;
1281 xmlCtxtDumpDocHead(ctxt, doc);
1282 if ((doc->intSubset !=
NULL) && (doc->intSubset->entities !=
NULL)) {
1284 doc->intSubset->entities;
1287 fprintf(ctxt->output,
"Entities in internal subset\n");
1290 fprintf(ctxt->output,
"No entities in internal subset\n");
1291 if ((doc->extSubset !=
NULL) && (doc->extSubset->entities !=
NULL)) {
1293 doc->extSubset->entities;
1296 fprintf(ctxt->output,
"Entities in external subset\n");
1298 }
else if (!ctxt->check)
1299 fprintf(ctxt->output,
"No entities in external subset\n");
1310xmlCtxtDumpDTD(xmlDebugCtxtPtr ctxt, xmlDtdPtr dtd)
1314 fprintf(ctxt->output,
"DTD is NULL\n");
1317 xmlCtxtDumpDtdNode(ctxt, dtd);
1318 if (dtd->children ==
NULL)
1319 fprintf(ctxt->output,
" DTD is empty\n");
1322 xmlCtxtDumpNodeList(ctxt, dtd->children);
1351 for (
i = 0;
i < 40;
i++)
1356 else if (
str[
i] >= 0x80)
1375 if (output ==
NULL)
return;
1376 xmlCtxtDumpInitCtxt(&ctxt);
1377 ctxt.output = output;
1379 xmlCtxtDumpAttr(&ctxt,
attr);
1380 xmlCtxtDumpCleanCtxt(&ctxt);
1392xmlDebugDumpEntities(
FILE * output, xmlDocPtr doc)
1396 if (output ==
NULL)
return;
1397 xmlCtxtDumpInitCtxt(&ctxt);
1398 ctxt.output = output;
1399 xmlCtxtDumpEntities(&ctxt, doc);
1400 xmlCtxtDumpCleanCtxt(&ctxt);
1412xmlDebugDumpAttrList(
FILE * output, xmlAttrPtr
attr,
int depth)
1416 if (output ==
NULL)
return;
1417 xmlCtxtDumpInitCtxt(&ctxt);
1418 ctxt.output = output;
1420 xmlCtxtDumpAttrList(&ctxt,
attr);
1421 xmlCtxtDumpCleanCtxt(&ctxt);
1433xmlDebugDumpOneNode(
FILE * output, xmlNodePtr
node,
int depth)
1437 if (output ==
NULL)
return;
1438 xmlCtxtDumpInitCtxt(&ctxt);
1439 ctxt.output = output;
1441 xmlCtxtDumpOneNode(&ctxt,
node);
1442 xmlCtxtDumpCleanCtxt(&ctxt);
1460 xmlCtxtDumpInitCtxt(&ctxt);
1461 ctxt.output = output;
1463 xmlCtxtDumpNode(&ctxt,
node);
1464 xmlCtxtDumpCleanCtxt(&ctxt);
1476xmlDebugDumpNodeList(
FILE * output, xmlNodePtr
node,
int depth)
1482 xmlCtxtDumpInitCtxt(&ctxt);
1483 ctxt.output = output;
1485 xmlCtxtDumpNodeList(&ctxt,
node);
1486 xmlCtxtDumpCleanCtxt(&ctxt);
1497xmlDebugDumpDocumentHead(
FILE * output, xmlDocPtr doc)
1503 xmlCtxtDumpInitCtxt(&ctxt);
1504 ctxt.options |= DUMP_TEXT_TYPE;
1505 ctxt.output = output;
1506 xmlCtxtDumpDocumentHead(&ctxt, doc);
1507 xmlCtxtDumpCleanCtxt(&ctxt);
1518xmlDebugDumpDocument(
FILE * output, xmlDocPtr doc)
1524 xmlCtxtDumpInitCtxt(&ctxt);
1525 ctxt.options |= DUMP_TEXT_TYPE;
1526 ctxt.output = output;
1527 xmlCtxtDumpDocument(&ctxt, doc);
1528 xmlCtxtDumpCleanCtxt(&ctxt);
1539xmlDebugDumpDTD(
FILE * output, xmlDtdPtr dtd)
1545 xmlCtxtDumpInitCtxt(&ctxt);
1546 ctxt.options |= DUMP_TEXT_TYPE;
1547 ctxt.output = output;
1548 xmlCtxtDumpDTD(&ctxt, dtd);
1549 xmlCtxtDumpCleanCtxt(&ctxt);
1569xmlDebugCheckDocument(
FILE * output, xmlDocPtr doc)
1575 xmlCtxtDumpInitCtxt(&ctxt);
1576 ctxt.output = output;
1578 xmlCtxtDumpDocument(&ctxt, doc);
1579 xmlCtxtDumpCleanCtxt(&ctxt);
1580 return(ctxt.errors);
1598xmlLsCountNode(xmlNodePtr
node) {
1605 switch (
node->type) {
1606 case XML_ELEMENT_NODE:
1609 case XML_DOCUMENT_NODE:
1610 case XML_HTML_DOCUMENT_NODE:
1611 list = ((xmlDocPtr)
node)->children;
1613 case XML_ATTRIBUTE_NODE:
1614 list = ((xmlAttrPtr)
node)->children;
1617 case XML_CDATA_SECTION_NODE:
1619 case XML_COMMENT_NODE:
1624 case XML_ENTITY_REF_NODE:
1625 case XML_DOCUMENT_TYPE_NODE:
1626 case XML_ENTITY_NODE:
1627 case XML_DOCUMENT_FRAG_NODE:
1628 case XML_NOTATION_NODE:
1630 case XML_ELEMENT_DECL:
1631 case XML_ATTRIBUTE_DECL:
1632 case XML_ENTITY_DECL:
1633 case XML_NAMESPACE_DECL:
1634 case XML_XINCLUDE_START:
1635 case XML_XINCLUDE_END:
1652xmlLsOneNode(
FILE *output, xmlNodePtr
node) {
1653 if (output ==
NULL)
return;
1658 switch (
node->type) {
1659 case XML_ELEMENT_NODE:
1662 case XML_ATTRIBUTE_NODE:
1668 case XML_CDATA_SECTION_NODE:
1671 case XML_ENTITY_REF_NODE:
1674 case XML_ENTITY_NODE:
1680 case XML_COMMENT_NODE:
1683 case XML_DOCUMENT_NODE:
1686 case XML_HTML_DOCUMENT_NODE:
1689 case XML_DOCUMENT_TYPE_NODE:
1692 case XML_DOCUMENT_FRAG_NODE:
1695 case XML_NOTATION_NODE:
1698 case XML_NAMESPACE_DECL:
1704 if (
node->type != XML_NAMESPACE_DECL) {
1717 switch (
node->type) {
1718 case XML_ELEMENT_NODE:
1725 case XML_ATTRIBUTE_NODE:
1731 xmlDebugDumpString(output,
node->content);
1734 case XML_CDATA_SECTION_NODE:
1736 case XML_ENTITY_REF_NODE:
1740 case XML_ENTITY_NODE:
1748 case XML_COMMENT_NODE:
1750 case XML_DOCUMENT_NODE:
1752 case XML_HTML_DOCUMENT_NODE:
1754 case XML_DOCUMENT_TYPE_NODE:
1756 case XML_DOCUMENT_FRAG_NODE:
1758 case XML_NOTATION_NODE:
1760 case XML_NAMESPACE_DECL: {
1761 xmlNsPtr
ns = (xmlNsPtr)
node;
1764 fprintf(output,
"default -> %s", (
char *)
ns->href);
1786xmlBoolToText(
int boolval)
1794#ifdef LIBXML_XPATH_ENABLED
1818xmlShellPrintXPathError(
int errorType,
const char *
arg)
1820 const char *default_arg =
"Result";
1825 switch (errorType) {
1826 case XPATH_UNDEFINED:
1828 "%s: no such node\n",
arg);
1833 "%s is a Boolean\n",
arg);
1837 "%s is a number\n",
arg);
1841 "%s is a string\n",
arg);
1843#ifdef LIBXML_XPTR_LOCS_ENABLED
1846 "%s is a point\n",
arg);
1850 "%s is a range\n",
arg);
1852 case XPATH_LOCATIONSET:
1854 "%s is a range\n",
arg);
1859 "%s is user-defined\n",
arg);
1861 case XPATH_XSLT_TREE:
1863 "%s is an XSLT value tree\n",
arg);
1868 "Try casting the result string function (xpath builtin)\n",
1874#ifdef LIBXML_OUTPUT_ENABLED
1883xmlShellPrintNodeCtxt(xmlShellCtxtPtr ctxt,xmlNodePtr
node)
1894 if (
node->type == XML_DOCUMENT_NODE)
1895 xmlDocDump(fp, (xmlDocPtr)
node);
1896 else if (
node->type == XML_ATTRIBUTE_NODE)
1897 xmlDebugDumpAttrList(fp, (xmlAttrPtr)
node, 0);
1911xmlShellPrintNode(xmlNodePtr
node)
1925xmlShellPrintXPathResultCtxt(xmlShellCtxtPtr ctxt,xmlXPathObjectPtr
list)
1931 switch (
list->type) {
1932 case XPATH_NODESET:{
1933#ifdef LIBXML_OUTPUT_ENABLED
1936 if (
list->nodesetval) {
1937 for (indx = 0; indx <
list->nodesetval->nodeNr;
1939 xmlShellPrintNodeCtxt(ctxt,
1940 list->nodesetval->nodeTab[indx]);
1944 "Empty node set\n");
1954 "Is a Boolean:%s\n",
1955 xmlBoolToText(
list->boolval));
1959 "Is a number:%0g\n",
list->floatval);
1963 "Is a string:%s\n",
list->stringval);
1967 xmlShellPrintXPathError(
list->type,
NULL);
1979xmlShellPrintXPathResult(xmlXPathObjectPtr
list)
1981 xmlShellPrintXPathResultCtxt(
NULL,
list);
1997xmlShellList(xmlShellCtxtPtr ctxt,
2005 fprintf(ctxt->output,
"NULL\n");
2008 if ((
node->type == XML_DOCUMENT_NODE) ||
2009 (
node->type == XML_HTML_DOCUMENT_NODE)) {
2010 cur = ((xmlDocPtr)
node)->children;
2011 }
else if (
node->type == XML_NAMESPACE_DECL) {
2012 xmlLsOneNode(ctxt->output,
node);
2014 }
else if (
node->children !=
NULL) {
2017 xmlLsOneNode(ctxt->output,
node);
2021 xmlLsOneNode(ctxt->output,
cur);
2040xmlShellBase(xmlShellCtxtPtr ctxt,
2048 fprintf(ctxt->output,
"NULL\n");
2055 fprintf(ctxt->output,
" No base found !!!\n");
2063#ifdef LIBXML_TREE_ENABLED
2086#ifdef LIBXML_XPATH_ENABLED
2101xmlShellRegisterNamespace(xmlShellCtxtPtr ctxt,
char *
arg,
2114 if((*
next) ==
'\0')
break;
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);
2162 if ((
root ==
NULL) || (
root->type != XML_ELEMENT_NODE) ||
2168 xmlXPathRegisterNs(ctxt->pctxt,
BAD_CAST "defaultns",
ns->href);
2170 xmlXPathRegisterNs(ctxt->pctxt,
ns->
prefix,
ns->href);
2199#ifdef LIBXML_REGEXP_ENABLED
2207 if (
node->type == XML_COMMENT_NODE) {
2210 fprintf(ctxt->output,
"%s : ", xmlGetNodePath(
node));
2213 }
else if (
node->type == XML_TEXT_NODE) {
2216 fprintf(ctxt->output,
"%s : ", xmlGetNodePath(
node->parent));
2225 if ((
node->type == XML_DOCUMENT_NODE) ||
2226 (
node->type == XML_HTML_DOCUMENT_NODE)) {
2227 node = ((xmlDocPtr)
node)->children;
2228 }
else if ((
node->children !=
NULL)
2229 && (
node->type != XML_ENTITY_REF_NODE)) {
2275 fprintf(ctxt->output,
"NULL\n");
2278 if ((
node->type == XML_DOCUMENT_NODE) ||
2279 (
node->type == XML_HTML_DOCUMENT_NODE)) {
2280 xmlDebugDumpDocumentHead(ctxt->output, (xmlDocPtr)
node);
2281 }
else if (
node->type == XML_ATTRIBUTE_NODE) {
2282 xmlDebugDumpAttr(ctxt->output, (xmlAttrPtr)
node, 0);
2284 xmlDebugDumpOneNode(ctxt->output,
node, 0);
2312 fprintf(ctxt->output,
"NULL\n");
2316 fprintf(ctxt->output,
"NULL\n");
2323 xmlFreeNodeList(
node->children);
2329 fprintf(ctxt->output,
"failed to parse content\n");
2334#ifdef LIBXML_SCHEMAS_ENABLED
2348xmlShellRNGValidate(xmlShellCtxtPtr sctxt,
char *schemas,
2352 xmlRelaxNGPtr relaxngschemas;
2353 xmlRelaxNGParserCtxtPtr ctxt;
2354 xmlRelaxNGValidCtxtPtr vctxt;
2357 ctxt = xmlRelaxNGNewParserCtxt(schemas);
2359 relaxngschemas = xmlRelaxNGParse(ctxt);
2360 xmlRelaxNGFreeParserCtxt(ctxt);
2361 if (relaxngschemas ==
NULL) {
2363 "Relax-NG schema %s failed to compile\n", schemas);
2366 vctxt = xmlRelaxNGNewValidCtxt(relaxngschemas);
2368 ret = xmlRelaxNGValidateDoc(vctxt, sctxt->doc);
2371 }
else if (
ret > 0) {
2374 fprintf(
stderr,
"%s validation generated an internal error\n",
2377 xmlRelaxNGFreeValidCtxt(vctxt);
2378 if (relaxngschemas !=
NULL)
2379 xmlRelaxNGFree(relaxngschemas);
2384#ifdef LIBXML_OUTPUT_ENABLED
2404 fprintf(ctxt->output,
"NULL\n");
2407 if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) {
2408#ifdef LIBXML_HTML_ENABLED
2409 if (
node->type == XML_HTML_DOCUMENT_NODE)
2410 htmlDocDump(ctxt->output, (htmlDocPtr)
node);
2412 htmlNodeDumpFile(ctxt->output, ctxt->doc,
node);
2414 if (
node->type == XML_DOCUMENT_NODE)
2415 xmlDocDump(ctxt->output, (xmlDocPtr)
node);
2417 xmlElemDump(ctxt->output, ctxt->doc,
node);
2420 if (
node->type == XML_DOCUMENT_NODE)
2421 xmlDocDump(ctxt->output, (xmlDocPtr)
node);
2423 xmlElemDump(ctxt->output, ctxt->doc,
node);
2443xmlShellLoad(xmlShellCtxtPtr ctxt,
char *
filename,
2451 if (ctxt->doc !=
NULL)
2452 html = (ctxt->doc->type == XML_HTML_DOCUMENT_NODE);
2455#ifdef LIBXML_HTML_ENABLED
2458 fprintf(ctxt->output,
"HTML support not compiled in\n");
2465 if (ctxt->loaded == 1) {
2466 xmlFreeDoc(ctxt->doc);
2469#ifdef LIBXML_XPATH_ENABLED
2470 xmlXPathFreeContext(ctxt->pctxt);
2474 ctxt->node = (xmlNodePtr) doc;
2475#ifdef LIBXML_XPATH_ENABLED
2476 ctxt->pctxt = xmlXPathNewContext(doc);
2484#ifdef LIBXML_OUTPUT_ENABLED
2499xmlShellWrite(xmlShellCtxtPtr ctxt,
char *
filename, xmlNodePtr
node,
2514 switch (
node->type) {
2515 case XML_DOCUMENT_NODE:
2516 if (xmlSaveFile((
char *)
filename, ctxt->doc) < -1) {
2518 "Failed to write to %s\n",
filename);
2522 case XML_HTML_DOCUMENT_NODE:
2523#ifdef LIBXML_HTML_ENABLED
2524 if (htmlSaveFile((
char *)
filename, ctxt->doc) < 0) {
2526 "Failed to write to %s\n",
filename);
2530 if (xmlSaveFile((
char *)
filename, ctxt->doc) < -1) {
2532 "Failed to write to %s\n",
filename);
2543 "Failed to write to %s\n",
filename);
2546 xmlElemDump(
f, ctxt->doc,
node);
2566xmlShellSave(xmlShellCtxtPtr ctxt,
char *
filename,
2570 if ((ctxt ==
NULL) || (ctxt->doc ==
NULL))
2583 switch (ctxt->doc->type) {
2584 case XML_DOCUMENT_NODE:
2585 if (xmlSaveFile((
char *)
filename, ctxt->doc) < 0) {
2587 "Failed to save to %s\n",
filename);
2590 case XML_HTML_DOCUMENT_NODE:
2591#ifdef LIBXML_HTML_ENABLED
2592 if (htmlSaveFile((
char *)
filename, ctxt->doc) < 0) {
2594 "Failed to save to %s\n",
filename);
2597 if (xmlSaveFile((
char *)
filename, ctxt->doc) < 0) {
2599 "Failed to save to %s\n",
filename);
2605 "To save to subparts of a document use the 'write' command\n");
2613#ifdef LIBXML_VALID_ENABLED
2628xmlShellValidate(xmlShellCtxtPtr ctxt,
char *dtd,
2635 if ((ctxt ==
NULL) || (ctxt->doc ==
NULL))
return(-1);
2636 memset(&vctxt, 0,
sizeof(vctxt));
2640 if ((dtd ==
NULL) || (dtd[0] == 0)) {
2641 res = xmlValidateDocument(&vctxt, ctxt->doc);
2646 if (subset !=
NULL) {
2647 res = xmlValidateDtd(&vctxt, ctxt->doc, subset);
2670xmlShellDu(xmlShellCtxtPtr ctxt,
2684 if ((
node->type == XML_DOCUMENT_NODE) ||
2685 (
node->type == XML_HTML_DOCUMENT_NODE)) {
2687 }
else if (
node->type == XML_ELEMENT_NODE) {
2690 if ((
node->ns) && (
node->ns->prefix))
2700 if ((
node->type == XML_DOCUMENT_NODE) ||
2701 (
node->type == XML_HTML_DOCUMENT_NODE)) {
2702 node = ((xmlDocPtr)
node)->children;
2703 }
else if ((
node->children !=
NULL)
2704 && (
node->type != XML_ENTITY_REF_NODE)) {
2794xmlShell(xmlDocPtr doc,
char *
filename, xmlShellReadlineFunc
input,
2797 char prompt[500] =
"/ > ";
2802 xmlShellCtxtPtr ctxt;
2803 xmlXPathObjectPtr
list;
2813 ctxt = (xmlShellCtxtPtr)
xmlMalloc(
sizeof(xmlShellCtxt));
2818 ctxt->input =
input;
2819 ctxt->output = output;
2821 ctxt->node = (xmlNodePtr) ctxt->doc;
2824 ctxt->pctxt = xmlXPathNewContext(ctxt->doc);
2825 if (ctxt->pctxt ==
NULL) {
2831 if (ctxt->node == (xmlNodePtr) ctxt->doc)
2832 snprintf(prompt,
sizeof(prompt),
"%s > ",
"/");
2833 else if ((ctxt->node !=
NULL) && (ctxt->node->name) &&
2834 (ctxt->node->ns) && (ctxt->node->ns->prefix))
2835 snprintf(prompt,
sizeof(prompt),
"%s:%s > ",
2836 (ctxt->node->ns->prefix), ctxt->node->name);
2837 else if ((ctxt->node !=
NULL) && (ctxt->node->name))
2838 snprintf(prompt,
sizeof(prompt),
"%s > ", ctxt->node->name);
2840 snprintf(prompt,
sizeof(prompt),
"? > ");
2841 prompt[
sizeof(prompt) - 1] = 0;
2846 cmdline = ctxt->input(prompt);
2854 while ((*
cur ==
' ') || (*
cur ==
'\t'))
2857 while ((*
cur !=
' ') && (*
cur !=
'\t') &&
2858 (*
cur !=
'\n') && (*
cur !=
'\r')) {
2870 while ((*
cur ==
' ') || (*
cur ==
'\t'))
2873 while ((*
cur !=
'\n') && (*
cur !=
'\r') && (*
cur != 0)) {
2890 fprintf(ctxt->output,
"\tbase display XML base of the node\n");
2891 fprintf(ctxt->output,
"\tsetbase URI change the XML base of the node\n");
2892 fprintf(ctxt->output,
"\tbye leave shell\n");
2893 fprintf(ctxt->output,
"\tcat [node] display node or current node\n");
2894 fprintf(ctxt->output,
"\tcd [path] change directory to path or to root\n");
2895 fprintf(ctxt->output,
"\tdir [path] dumps information about the node (namespace, attributes, content)\n");
2896 fprintf(ctxt->output,
"\tdu [path] show the structure of the subtree under path or the current node\n");
2897 fprintf(ctxt->output,
"\texit leave shell\n");
2898 fprintf(ctxt->output,
"\thelp display this help\n");
2899 fprintf(ctxt->output,
"\tfree display memory usage\n");
2900 fprintf(ctxt->output,
"\tload [name] load a new document with name\n");
2901 fprintf(ctxt->output,
"\tls [path] list contents of path or the current directory\n");
2902 fprintf(ctxt->output,
"\tset xml_fragment replace the current node content with the fragment parsed in context\n");
2903#ifdef LIBXML_XPATH_ENABLED
2904 fprintf(ctxt->output,
"\txpath expr evaluate the XPath expression in that context and print the result\n");
2905 fprintf(ctxt->output,
"\tsetns nsreg register a namespace to a prefix in the XPath evaluation context\n");
2906 fprintf(ctxt->output,
"\t format for nsreg is: prefix=[nsuri] (i.e. prefix= unsets a prefix)\n");
2907 fprintf(ctxt->output,
"\tsetrootns register all namespace found on the root element\n");
2908 fprintf(ctxt->output,
"\t the default namespace if any uses 'defaultns' prefix\n");
2910 fprintf(ctxt->output,
"\tpwd display current working directory\n");
2911 fprintf(ctxt->output,
"\twhereis display absolute path of [path] or current working directory\n");
2912 fprintf(ctxt->output,
"\tquit leave shell\n");
2913#ifdef LIBXML_OUTPUT_ENABLED
2914 fprintf(ctxt->output,
"\tsave [name] save this document to name or the original name\n");
2915 fprintf(ctxt->output,
"\twrite [name] write the current node to the filename\n");
2917#ifdef LIBXML_VALID_ENABLED
2918 fprintf(ctxt->output,
"\tvalidate check the document for errors\n");
2920#ifdef LIBXML_SCHEMAS_ENABLED
2921 fprintf(ctxt->output,
"\trelaxng rng validate the document against the Relax-NG schemas\n");
2923 fprintf(ctxt->output,
"\tgrep string search for a string in the subtree\n");
2924#ifdef LIBXML_VALID_ENABLED
2930#ifdef LIBXML_SCHEMAS_ENABLED
2934#ifdef LIBXML_OUTPUT_ENABLED
2940 "Write command requires a filename argument\n");
2942 xmlShellWrite(ctxt,
arg, ctxt->node,
NULL);
2945 xmlShellGrep(ctxt,
arg, ctxt->node,
NULL);
2958 if (!xmlShellPwd(ctxt,
dir, ctxt->node,
NULL))
2962 xmlShellDu(ctxt,
NULL, ctxt->node,
NULL);
2964 ctxt->pctxt->node = ctxt->node;
2965#ifdef LIBXML_XPATH_ENABLED
2966 ctxt->pctxt->node = ctxt->node;
2972 switch (
list->type) {
2973 case XPATH_UNDEFINED:
2975 "%s: no such node\n",
arg);
2977 case XPATH_NODESET:{
2984 indx <
list->nodesetval->nodeNr;
2986 xmlShellDu(ctxt,
NULL,
2988 nodeTab[indx],
NULL);
2993 "%s is a Boolean\n",
arg);
2997 "%s is a number\n",
arg);
3001 "%s is a string\n",
arg);
3003#ifdef LIBXML_XPTR_LOCS_ENABLED
3006 "%s is a point\n",
arg);
3010 "%s is a range\n",
arg);
3012 case XPATH_LOCATIONSET:
3014 "%s is a range\n",
arg);
3019 "%s is user-defined\n",
arg);
3021 case XPATH_XSLT_TREE:
3023 "%s is an XSLT value tree\n",
3027#ifdef LIBXML_XPATH_ENABLED
3028 xmlXPathFreeObject(
list);
3032 "%s: no such node\n",
arg);
3034 ctxt->pctxt->node =
NULL;
3037 xmlShellBase(ctxt,
NULL, ctxt->node,
NULL);
3039 xmlShellSetContent(ctxt,
arg, ctxt->node,
NULL);
3040#ifdef LIBXML_XPATH_ENABLED
3044 "setns: prefix=[nsuri] required\n");
3051 root = xmlDocGetRootElement(ctxt->doc);
3052 xmlShellRegisterRootNamespaces(ctxt,
NULL,
root,
NULL);
3056 "xpath: expression required\n");
3058 ctxt->pctxt->node = ctxt->node;
3060 xmlXPathDebugDumpObject(ctxt->output,
list, 0);
3061 xmlXPathFreeObject(
list);
3064#ifdef LIBXML_TREE_ENABLED
3066 xmlShellSetBase(ctxt,
arg, ctxt->node,
NULL);
3073 xmlShellDir(ctxt,
NULL, ctxt->node,
NULL);
3075 xmlShellList(ctxt,
NULL, ctxt->node,
NULL);
3077 ctxt->pctxt->node = ctxt->node;
3078#ifdef LIBXML_XPATH_ENABLED
3079 ctxt->pctxt->node = ctxt->node;
3085 switch (
list->type) {
3086 case XPATH_UNDEFINED:
3088 "%s: no such node\n",
arg);
3090 case XPATH_NODESET:{
3097 indx <
list->nodesetval->nodeNr;
3100 xmlShellDir(ctxt,
NULL,
3102 nodeTab[indx],
NULL);
3104 xmlShellList(ctxt,
NULL,
3106 nodeTab[indx],
NULL);
3112 "%s is a Boolean\n",
arg);
3116 "%s is a number\n",
arg);
3120 "%s is a string\n",
arg);
3122#ifdef LIBXML_XPTR_LOCS_ENABLED
3125 "%s is a point\n",
arg);
3129 "%s is a range\n",
arg);
3131 case XPATH_LOCATIONSET:
3133 "%s is a range\n",
arg);
3138 "%s is user-defined\n",
arg);
3140 case XPATH_XSLT_TREE:
3142 "%s is an XSLT value tree\n",
3146#ifdef LIBXML_XPATH_ENABLED
3147 xmlXPathFreeObject(
list);
3151 "%s: no such node\n",
arg);
3153 ctxt->pctxt->node =
NULL;
3159 if (!xmlShellPwd(ctxt,
dir, ctxt->node,
NULL))
3162 ctxt->pctxt->node = ctxt->node;
3163#ifdef LIBXML_XPATH_ENABLED
3169 switch (
list->type) {
3170 case XPATH_UNDEFINED:
3172 "%s: no such node\n",
arg);
3174 case XPATH_NODESET:{
3181 indx <
list->nodesetval->nodeNr;
3183 if (!xmlShellPwd(ctxt,
dir,
list->nodesetval->
3184 nodeTab[indx],
NULL))
3191 "%s is a Boolean\n",
arg);
3195 "%s is a number\n",
arg);
3199 "%s is a string\n",
arg);
3201#ifdef LIBXML_XPTR_LOCS_ENABLED
3204 "%s is a point\n",
arg);
3208 "%s is a range\n",
arg);
3210 case XPATH_LOCATIONSET:
3212 "%s is a range\n",
arg);
3217 "%s is user-defined\n",
arg);
3219 case XPATH_XSLT_TREE:
3221 "%s is an XSLT value tree\n",
3225#ifdef LIBXML_XPATH_ENABLED
3226 xmlXPathFreeObject(
list);
3230 "%s: no such node\n",
arg);
3232 ctxt->pctxt->node =
NULL;
3236 ctxt->node = (xmlNodePtr) ctxt->doc;
3238#ifdef LIBXML_XPATH_ENABLED
3241 ctxt->pctxt->node = ctxt->node;
3243 if ((
l >= 2) && (
arg[
l - 1] ==
'/'))
3250 switch (
list->type) {
3251 case XPATH_UNDEFINED:
3253 "%s: no such node\n",
arg);
3257 if (
list->nodesetval->nodeNr == 1) {
3258 ctxt->node =
list->nodesetval->nodeTab[0];
3259 if ((ctxt->node !=
NULL) &&
3260 (ctxt->node->type ==
3261 XML_NAMESPACE_DECL)) {
3263 "cannot cd to namespace\n");
3268 "%s is a %d Node Set\n",
3270 list->nodesetval->nodeNr);
3273 "%s is an empty Node Set\n",
3278 "%s is a Boolean\n",
arg);
3282 "%s is a number\n",
arg);
3286 "%s is a string\n",
arg);
3288#ifdef LIBXML_XPTR_LOCS_ENABLED
3291 "%s is a point\n",
arg);
3295 "%s is a range\n",
arg);
3297 case XPATH_LOCATIONSET:
3299 "%s is a range\n",
arg);
3304 "%s is user-defined\n",
arg);
3306 case XPATH_XSLT_TREE:
3308 "%s is an XSLT value tree\n",
3312#ifdef LIBXML_XPATH_ENABLED
3313 xmlXPathFreeObject(
list);
3317 "%s: no such node\n",
arg);
3319 ctxt->pctxt->node =
NULL;
3321#ifdef LIBXML_OUTPUT_ENABLED
3324 xmlShellCat(ctxt,
NULL, ctxt->node,
NULL);
3326 ctxt->pctxt->node = ctxt->node;
3327#ifdef LIBXML_XPATH_ENABLED
3328 ctxt->pctxt->node = ctxt->node;
3334 switch (
list->type) {
3335 case XPATH_UNDEFINED:
3337 "%s: no such node\n",
arg);
3339 case XPATH_NODESET:{
3346 indx <
list->nodesetval->nodeNr;
3349 fprintf(ctxt->output,
" -------\n");
3350 xmlShellCat(ctxt,
NULL,
3352 nodeTab[indx],
NULL);
3358 "%s is a Boolean\n",
arg);
3362 "%s is a number\n",
arg);
3366 "%s is a string\n",
arg);
3368#ifdef LIBXML_XPTR_LOCS_ENABLED
3371 "%s is a point\n",
arg);
3375 "%s is a range\n",
arg);
3377 case XPATH_LOCATIONSET:
3379 "%s is a range\n",
arg);
3384 "%s is user-defined\n",
arg);
3386 case XPATH_XSLT_TREE:
3388 "%s is an XSLT value tree\n",
3392#ifdef LIBXML_XPATH_ENABLED
3393 xmlXPathFreeObject(
list);
3397 "%s: no such node\n",
arg);
3399 ctxt->pctxt->node =
NULL;
3404 "Unknown command %s\n",
command);
3409#ifdef LIBXML_XPATH_ENABLED
3410 xmlXPathFreeContext(ctxt->pctxt);
3413 xmlFreeDoc(ctxt->doc);
3415 if (ctxt->filename !=
NULL)
static struct _test_info results[8]
static const WCHAR indent[]
int CDECL fclose(FILE *file)
int WINAPIV fprintf(FILE *file, const char *format,...)
FILE *CDECL fopen(const char *path, const char *mode)
int CDECL fputc(int c, FILE *file)
_ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl sscanf(const char *, const char *,...) __WINE_CRT_SCANF_ATTR(2
_ACRTIMP size_t __cdecl strlen(const char *)
_ACRTIMP int __cdecl strcmp(const char *, const char *)
#define check(expected, result)
GLint GLint GLsizei GLsizei GLsizei depth
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLint GLboolean GLint GLenum access
GLenum GLenum GLenum input
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
XMLPUBFUN xmlEntityPtr xmlGetDocEntity(const xmlDoc *doc, const xmlChar *name)
@ XML_EXTERNAL_GENERAL_PARSED_ENTITY
@ XML_INTERNAL_PREDEFINED_ENTITY
@ XML_EXTERNAL_GENERAL_UNPARSED_ENTITY
@ XML_INTERNAL_GENERAL_ENTITY
@ XML_INTERNAL_PARAMETER_ENTITY
@ XML_EXTERNAL_PARAMETER_ENTITY
xmlEntitiesTable * xmlEntitiesTablePtr
XMLPUBVAR const xmlChar xmlStringComment[]
XMLPUBVAR const xmlChar xmlStringTextNoenc[]
XMLPUBVAR const xmlChar xmlStringText[]
static unsigned __int64 next
int xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
const xmlChar * xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
void * xmlGenericErrorContext
xmlGenericErrorFunc xmlGenericError
void xmlHashScan(xmlHashTablePtr hash, xmlHashScanner scan, void *data)
XMLPUBFUN xmlParserErrors xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen, int options, xmlNodePtr *lst)
XMLPUBFUN xmlDocPtr xmlReadFile(const char *URL, const char *encoding, int options)
XML_HIDDEN void __xmlRaiseError(xmlStructuredErrorFunc schannel, xmlGenericErrorFunc channel, void *data, void *ctx, void *nod, int domain, int code, xmlErrorLevel level, const char *file, int line, const char *str1, const char *str2, const char *str3, int int1, int col, const char *msg,...) LIBXML_ATTR_FORMAT(16
Character const *const prefix
XMLPUBFUN xmlChar * xmlCanonicPath(const xmlChar *path)
XMLPUBFUN void xmlSnprintfElementContent(char *buf, int size, xmlElementContentPtr content, int englob)
typedeftypedef void(*) typedef void(*) struct _xmlValidCtx xmlValidCtxt)
@ XML_CHECK_FOUND_ELEMENT
@ XML_CHECK_FOUND_ATTRIBUTE
@ XML_CHECK_FOUND_NOTATION
@ XML_CHECK_FOUND_DOCTYPE
@ XML_CHECK_FOUND_FRAGMENT
@ XML_CHECK_FOUND_COMMENT
@ XML_CHECK_NOT_ELEM_DECL
@ XML_CHECK_NOT_ATTR_DECL
@ XML_CHECK_NOT_ENTITY_DECL
@ XML_CHECK_FOUND_ENTITYREF
@ XML_CHECK_NAME_NOT_NULL
XMLPUBFUN void xmlMemShow(FILE *fp, int nr)
XMLPUBFUN int xmlStrlen(const xmlChar *str)
XMLPUBFUN const xmlChar * xmlStrstr(const xmlChar *str, const xmlChar *val)
XMLPUBFUN int xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
XMLPUBFUN const xmlChar * xmlStrchr(const xmlChar *str, xmlChar val)
XMLPUBFUN int xmlCheckUTF8(const unsigned char *utf)
XMLPUBFUN xmlChar * xmlStrdup(const xmlChar *cur)
#define LIBXML_XPATH_ENABLED
#define LIBXML_ATTR_FORMAT(fmt, args)