12#ifdef LIBXML_DEBUG_ENABLED
29#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++)
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)
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);
279 "Node has no parent\n");
282 "Node has no doc\n");
286 if ((dict ==
NULL) && (ctxt->nodict == 0)) {
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");
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");
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");
340 xmlCtxtNsCheckScope(ctxt,
node,
ns);
344 xmlCtxtNsCheckScope(ctxt,
node,
node->ns);
347 xmlCtxtNsCheckScope(ctxt,
node,
node->ns);
358 xmlCtxtCheckString(ctxt, (
const xmlChar *)
node->content);
360 switch (
node->type) {
363 xmlCtxtCheckName(ctxt,
node->name);
370 if ((ctxt->dict !=
NULL) &&
376 "Text node has wrong name '%s'",
377 (
const char *)
node->name);
383 "Comment node has wrong name '%s'",
384 (
const char *)
node->name);
387 xmlCtxtCheckName(ctxt,
node->name);
393 "CData section has non NULL name '%s'",
394 (
const char *)
node->name);
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");
452 "Node is not a DTD");
457 fprintf(ctxt->output,
"DTD(%s)", (
char *) dtd->
name);
469 xmlCtxtGenericNodeCheck(ctxt, (
xmlNodePtr) dtd);
475 xmlCtxtDumpSpaces(ctxt);
479 fprintf(ctxt->output,
"Attribute declaration is NULL\n");
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) {
502 fprintf(ctxt->output,
" CDATA");
508 fprintf(ctxt->output,
" IDREF");
511 fprintf(ctxt->output,
" IDREFS");
514 fprintf(ctxt->output,
" ENTITY");
517 fprintf(ctxt->output,
" ENTITIES");
520 fprintf(ctxt->output,
" NMTOKEN");
523 fprintf(ctxt->output,
" NMTOKENS");
526 fprintf(ctxt->output,
" ENUMERATION");
529 fprintf(ctxt->output,
" NOTATION ");
536 for (indx = 0; indx < 5; indx++) {
538 fprintf(ctxt->output,
"|%s", (
char *)
cur->name);
540 fprintf(ctxt->output,
" (%s", (
char *)
cur->name);
554 fprintf(ctxt->output,
" REQUIRED");
557 fprintf(ctxt->output,
" IMPLIED");
560 fprintf(ctxt->output,
" FIXED");
565 xmlCtxtDumpString(ctxt,
attr->defaultValue);
580 xmlCtxtDumpSpaces(ctxt);
584 fprintf(ctxt->output,
"Element declaration is NULL\n");
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) {
604 fprintf(ctxt->output,
", UNDEFINED");
607 fprintf(ctxt->output,
", EMPTY");
610 fprintf(ctxt->output,
", ANY");
613 fprintf(ctxt->output,
", MIXED ");
616 fprintf(ctxt->output,
", MIXED ");
637xmlCtxtDumpEntityDecl(xmlDebugCtxtPtr ctxt,
xmlEntityPtr ent)
639 xmlCtxtDumpSpaces(ctxt);
643 fprintf(ctxt->output,
"Entity declaration is NULL\n");
648 "Node is not an entity declaration");
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");
682 xmlCtxtDumpSpaces(ctxt);
683 fprintf(ctxt->output,
" ExternalID=%s\n",
687 xmlCtxtDumpSpaces(ctxt);
688 fprintf(ctxt->output,
" SystemID=%s\n",
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");
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);
787 xmlCtxtDumpSpaces(ctxt);
788 fprintf(ctxt->output,
"ExternalID=%s\n",
792 xmlCtxtDumpSpaces(ctxt);
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);
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");
858 xmlCtxtDumpAttr(ctxt,
attr);
876 xmlCtxtDumpSpaces(ctxt);
877 fprintf(ctxt->output,
"node is NULL\n");
883 switch (
node->type) {
886 xmlCtxtDumpSpaces(ctxt);
887 fprintf(ctxt->output,
"ELEMENT ");
889 xmlCtxtDumpString(ctxt,
node->ns->prefix);
892 xmlCtxtDumpString(ctxt,
node->name);
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");
922 xmlCtxtDumpSpaces(ctxt);
923 fprintf(ctxt->output,
"CDATA_SECTION\n");
928 xmlCtxtDumpSpaces(ctxt);
929 fprintf(ctxt->output,
"ENTITY_REF(%s)\n",
930 (
char *)
node->name);
935 xmlCtxtDumpSpaces(ctxt);
936 fprintf(ctxt->output,
"ENTITY\n");
941 xmlCtxtDumpSpaces(ctxt);
942 fprintf(ctxt->output,
"PI %s\n", (
char *)
node->name);
947 xmlCtxtDumpSpaces(ctxt);
948 fprintf(ctxt->output,
"COMMENT\n");
954 xmlCtxtDumpSpaces(ctxt);
956 fprintf(ctxt->output,
"Error, DOCUMENT found here\n");
957 xmlCtxtGenericNodeCheck(ctxt,
node);
961 xmlCtxtDumpSpaces(ctxt);
962 fprintf(ctxt->output,
"DOCUMENT_TYPE\n");
967 xmlCtxtDumpSpaces(ctxt);
968 fprintf(ctxt->output,
"DOCUMENT_FRAG\n");
973 xmlCtxtDumpSpaces(ctxt);
974 fprintf(ctxt->output,
"NOTATION\n");
994 xmlCtxtDumpSpaces(ctxt);
995 fprintf(ctxt->output,
"INCLUDE START\n");
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");
1019 xmlCtxtDumpNamespaceList(ctxt,
node->nsDef);
1021 xmlCtxtDumpAttrList(ctxt,
node->properties);
1025 xmlCtxtDumpSpaces(ctxt);
1026 fprintf(ctxt->output,
"content=");
1027 xmlCtxtDumpString(ctxt,
node->content);
1036 xmlCtxtDumpEntity(ctxt, ent);
1043 xmlCtxtGenericNodeCheck(ctxt,
node);
1059 xmlCtxtDumpSpaces(ctxt);
1060 fprintf(ctxt->output,
"node is NULL\n");
1064 xmlCtxtDumpOneNode(ctxt,
node);
1068 xmlCtxtDumpNodeList(ctxt,
node->children);
1085 xmlCtxtDumpNode(ctxt,
node);
1091xmlCtxtDumpDocHead(xmlDebugCtxtPtr ctxt,
xmlDocPtr doc)
1095 fprintf(ctxt->output,
"DOCUMENT == NULL !\n");
1100 switch (doc->
type) {
1103 "Misplaced ELEMENT node\n");
1107 "Misplaced ATTRIBUTE node\n");
1111 "Misplaced TEXT node\n");
1115 "Misplaced CDATA node\n");
1119 "Misplaced ENTITYREF node\n");
1123 "Misplaced ENTITY node\n");
1127 "Misplaced PI node\n");
1131 "Misplaced COMMENT node\n");
1135 fprintf(ctxt->output,
"DOCUMENT\n");
1139 fprintf(ctxt->output,
"HTML DOCUMENT\n");
1143 "Misplaced DOCTYPE node\n");
1147 "Misplaced FRAGMENT node\n");
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);
1173 fprintf(ctxt->output,
"name=");
1178 fprintf(ctxt->output,
"version=");
1179 xmlCtxtDumpString(ctxt, doc->
version);
1183 fprintf(ctxt->output,
"encoding=");
1184 xmlCtxtDumpString(ctxt, doc->
encoding);
1188 fprintf(ctxt->output,
"URL=");
1189 xmlCtxtDumpString(ctxt, doc->
URL);
1193 fprintf(ctxt->output,
"standalone=true\n");
1196 xmlCtxtDumpNamespaceList(ctxt, doc->
oldNs);
1207xmlCtxtDumpDocument(xmlDebugCtxtPtr ctxt,
xmlDocPtr doc)
1211 fprintf(ctxt->output,
"DOCUMENT == NULL !\n");
1214 xmlCtxtDumpDocumentHead(ctxt, doc);
1219 xmlCtxtDumpNodeList(ctxt, doc->
children);
1225xmlCtxtDumpEntityCallback(
void *payload,
void *
data,
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);
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);
1287 fprintf(ctxt->output,
"Entities in internal subset\n");
1290 fprintf(ctxt->output,
"No entities in internal subset\n");
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);
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);
1396 if (output ==
NULL)
return;
1397 xmlCtxtDumpInitCtxt(&ctxt);
1398 ctxt.output = output;
1399 xmlCtxtDumpEntities(&ctxt, doc);
1400 xmlCtxtDumpCleanCtxt(&ctxt);
1416 if (output ==
NULL)
return;
1417 xmlCtxtDumpInitCtxt(&ctxt);
1418 ctxt.output = output;
1420 xmlCtxtDumpAttrList(&ctxt,
attr);
1421 xmlCtxtDumpCleanCtxt(&ctxt);
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);
1482 xmlCtxtDumpInitCtxt(&ctxt);
1483 ctxt.output = output;
1485 xmlCtxtDumpNodeList(&ctxt,
node);
1486 xmlCtxtDumpCleanCtxt(&ctxt);
1503 xmlCtxtDumpInitCtxt(&ctxt);
1504 ctxt.options |= DUMP_TEXT_TYPE;
1505 ctxt.output = output;
1506 xmlCtxtDumpDocumentHead(&ctxt, doc);
1507 xmlCtxtDumpCleanCtxt(&ctxt);
1524 xmlCtxtDumpInitCtxt(&ctxt);
1525 ctxt.options |= DUMP_TEXT_TYPE;
1526 ctxt.output = output;
1527 xmlCtxtDumpDocument(&ctxt, doc);
1528 xmlCtxtDumpCleanCtxt(&ctxt);
1545 xmlCtxtDumpInitCtxt(&ctxt);
1546 ctxt.options |= DUMP_TEXT_TYPE;
1547 ctxt.output = output;
1548 xmlCtxtDumpDTD(&ctxt, dtd);
1549 xmlCtxtDumpCleanCtxt(&ctxt);
1575 xmlCtxtDumpInitCtxt(&ctxt);
1576 ctxt.output = output;
1578 xmlCtxtDumpDocument(&ctxt, doc);
1579 xmlCtxtDumpCleanCtxt(&ctxt);
1580 return(ctxt.errors);
1605 switch (
node->type) {
1653 if (output ==
NULL)
return;
1658 switch (
node->type) {
1717 switch (
node->type) {
1731 xmlDebugDumpString(output,
node->content);
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
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");
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);
2168 xmlXPathRegisterNs(ctxt->pctxt,
BAD_CAST "defaultns",
ns->href);
2170 xmlXPathRegisterNs(ctxt->pctxt,
ns->
prefix,
ns->href);
2199#ifdef LIBXML_REGEXP_ENABLED
2210 fprintf(ctxt->output,
"%s : ", xmlGetNodePath(
node));
2216 fprintf(ctxt->output,
"%s : ", xmlGetNodePath(
node->parent));
2228 }
else if ((
node->children !=
NULL)
2275 fprintf(ctxt->output,
"NULL\n");
2284 xmlDebugDumpOneNode(ctxt->output,
node, 0);
2312 fprintf(ctxt->output,
"NULL\n");
2316 fprintf(ctxt->output,
"NULL\n");
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");
2408#ifdef LIBXML_HTML_ENABLED
2410 htmlDocDump(ctxt->output, (htmlDocPtr)
node);
2412 htmlNodeDumpFile(ctxt->output, ctxt->doc,
node);
2417 xmlElemDump(ctxt->output, ctxt->doc,
node);
2423 xmlElemDump(ctxt->output, ctxt->doc,
node);
2443xmlShellLoad(xmlShellCtxtPtr ctxt,
char *
filename,
2451 if (ctxt->doc !=
NULL)
2455#ifdef LIBXML_HTML_ENABLED
2458 fprintf(ctxt->output,
"HTML support not compiled in\n");
2465 if (ctxt->loaded == 1) {
2469#ifdef LIBXML_XPATH_ENABLED
2470 xmlXPathFreeContext(ctxt->pctxt);
2475#ifdef LIBXML_XPATH_ENABLED
2476 ctxt->pctxt = xmlXPathNewContext(doc);
2484#ifdef LIBXML_OUTPUT_ENABLED
2514 switch (
node->type) {
2516 if (xmlSaveFile((
char *)
filename, ctxt->doc) < -1) {
2518 "Failed to write to %s\n",
filename);
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) {
2585 if (xmlSaveFile((
char *)
filename, ctxt->doc) < 0) {
2587 "Failed to save to %s\n",
filename);
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 vctxt.userData =
NULL;
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,
2690 if ((
node->ns) && (
node->ns->prefix))
2703 }
else if ((
node->children !=
NULL)
2797 char prompt[500] =
"/ > ";
2802 xmlShellCtxtPtr ctxt;
2803 xmlXPathObjectPtr
list;
2813 ctxt = (xmlShellCtxtPtr)
xmlMalloc(
sizeof(xmlShellCtxt));
2818 ctxt->input =
input;
2819 ctxt->output = output;
2824 ctxt->pctxt = xmlXPathNewContext(ctxt->doc);
2825 if (ctxt->pctxt ==
NULL) {
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");
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;
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 ==
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);
3415 if (ctxt->filename !=
NULL)
static struct _test_info results[8]
int strcmp(const char *String1, const char *String2)
ACPI_SIZE strlen(const char *String)
static const WCHAR indent[]
#define check(expected, result)
XMLPUBFUN xmlEntityPtr XMLCALL 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
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
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
XMLPUBVAR const xmlChar xmlStringComment[]
XMLPUBVAR const xmlChar xmlStringTextNoenc[]
XMLPUBVAR const xmlChar xmlStringText[]
static unsigned __int64 next
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
XMLPUBFUN int XMLCALL xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
XMLPUBVAR xmlMallocFunc xmlMalloc
XMLPUBVAR xmlFreeFunc xmlFree
XMLPUBVAR void * xmlGenericErrorContext
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
XMLPUBFUN void XMLCALL xmlHashScan(xmlHashTablePtr table, xmlHashScanner f, void *data)
XMLPUBFUN xmlDocPtr XMLCALL xmlReadFile(const char *URL, const char *encoding, int options)
XMLPUBFUN xmlParserErrors XMLCALL xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen, int options, xmlNodePtr *lst)
XMLPUBFUN xmlNodePtr XMLCALL xmlDocGetRootElement(const xmlDoc *doc)
@ XML_ATTRIBUTE_ENUMERATION
XMLPUBFUN void XMLCALL xmlFreeDtd(xmlDtdPtr cur)
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
XMLPUBFUN xmlChar *XMLCALL xmlNodeGetBase(const xmlDoc *doc, const xmlNode *cur)
XMLPUBFUN void XMLCALL xmlFreeNodeList(xmlNodePtr cur)
@ XML_ELEMENT_TYPE_UNDEFINED
@ XML_ELEMENT_TYPE_ELEMENT
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur)
struct _xmlDtd * intSubset
struct _xmlNode * children
struct _xmlDtd * extSubset
struct _xmlNode * children
const xmlChar * ExternalID
const xmlChar * ExternalID
XMLPUBFUN xmlChar *XMLCALL xmlCanonicPath(const xmlChar *path)
XMLPUBFUN void XMLCALL xmlSnprintfElementContent(char *buf, int size, xmlElementContentPtr content, int englob)
typedeftypedef void(XMLCDECL *) typedef void(XMLCDECL *) 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 XMLCALL xmlMemShow(FILE *fp, int nr)
XMLPUBFUN const xmlChar *XMLCALL xmlStrchr(const xmlChar *str, xmlChar val)
XMLPUBFUN const xmlChar *XMLCALL xmlStrstr(const xmlChar *str, const xmlChar *val)
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
XMLPUBFUN int XMLCALL xmlCheckUTF8(const unsigned char *utf)
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
#define LIBXML_XPATH_ENABLED
#define LIBXML_ATTR_FORMAT(fmt, args)