Lines Matching +full:- +full:- +full:output +full:- +full:document

42     FILE *output;               /* the output file */  member
45 xmlDocPtr doc; /* current document */
50 int nodict; /* if the document has no dictionary */
61 ctxt->depth = 0; in xmlCtxtDumpInitCtxt()
62 ctxt->check = 0; in xmlCtxtDumpInitCtxt()
63 ctxt->errors = 0; in xmlCtxtDumpInitCtxt()
64 ctxt->output = stdout; in xmlCtxtDumpInitCtxt()
65 ctxt->doc = NULL; in xmlCtxtDumpInitCtxt()
66 ctxt->node = NULL; in xmlCtxtDumpInitCtxt()
67 ctxt->dict = NULL; in xmlCtxtDumpInitCtxt()
68 ctxt->nodict = 0; in xmlCtxtDumpInitCtxt()
69 ctxt->options = 0; in xmlCtxtDumpInitCtxt()
71 ctxt->shift[i] = ' '; in xmlCtxtDumpInitCtxt()
72 ctxt->shift[100] = 0; in xmlCtxtDumpInitCtxt()
88 * Returns 1 if in scope, -1 in case of argument error,
89 * -2 if the namespace is not in scope, and -3 if not on
98 return(-1); in xmlNsCheckScope()
100 if ((node->type != XML_ELEMENT_NODE) && in xmlNsCheckScope()
101 (node->type != XML_ATTRIBUTE_NODE) && in xmlNsCheckScope()
102 (node->type != XML_DOCUMENT_NODE) && in xmlNsCheckScope()
103 (node->type != XML_TEXT_NODE) && in xmlNsCheckScope()
104 (node->type != XML_HTML_DOCUMENT_NODE) && in xmlNsCheckScope()
105 (node->type != XML_XINCLUDE_START)) in xmlNsCheckScope()
106 return(-2); in xmlNsCheckScope()
109 ((node->type == XML_ELEMENT_NODE) || in xmlNsCheckScope()
110 (node->type == XML_ATTRIBUTE_NODE) || in xmlNsCheckScope()
111 (node->type == XML_TEXT_NODE) || in xmlNsCheckScope()
112 (node->type == XML_XINCLUDE_START))) { in xmlNsCheckScope()
113 if ((node->type == XML_ELEMENT_NODE) || in xmlNsCheckScope()
114 (node->type == XML_XINCLUDE_START)) { in xmlNsCheckScope()
115 cur = node->nsDef; in xmlNsCheckScope()
119 if (xmlStrEqual(cur->prefix, ns->prefix)) in xmlNsCheckScope()
120 return(-2); in xmlNsCheckScope()
121 cur = cur->next; in xmlNsCheckScope()
124 node = node->parent; in xmlNsCheckScope()
126 /* the xml namespace may be declared on the document node */ in xmlNsCheckScope()
128 ((node->type == XML_DOCUMENT_NODE) || in xmlNsCheckScope()
129 (node->type == XML_HTML_DOCUMENT_NODE))) { in xmlNsCheckScope()
130 xmlNsPtr oldNs = ((xmlDocPtr) node)->oldNs; in xmlNsCheckScope()
134 return(-3); in xmlNsCheckScope()
140 if (ctxt->check) in xmlCtxtDumpSpaces()
142 if ((ctxt->output != NULL) && (ctxt->depth > 0)) { in xmlCtxtDumpSpaces()
143 if (ctxt->depth < 50) in xmlCtxtDumpSpaces()
144 fprintf(ctxt->output, "%s", &ctxt->shift[100 - 2 * ctxt->depth]); in xmlCtxtDumpSpaces()
146 fprintf(ctxt->output, "%s", ctxt->shift); in xmlCtxtDumpSpaces()
160 ctxt->errors++; in xmlDebugErr()
162 NULL, ctxt->node, XML_FROM_CHECK, in xmlDebugErr()
170 ctxt->errors++; in xmlDebugErr2()
172 NULL, ctxt->node, XML_FROM_CHECK, in xmlDebugErr2()
180 ctxt->errors++; in xmlDebugErr3()
182 NULL, ctxt->node, XML_FROM_CHECK, in xmlDebugErr3()
202 if (ret == -2) { in xmlCtxtNsCheckScope()
203 if (ns->prefix == NULL) in xmlCtxtNsCheckScope()
209 (char *) ns->prefix); in xmlCtxtNsCheckScope()
211 if (ret == -3) { in xmlCtxtNsCheckScope()
212 if (ns->prefix == NULL) in xmlCtxtNsCheckScope()
218 (char *) ns->prefix); in xmlCtxtNsCheckScope()
227 * Do debugging on the string, currently it just checks the UTF-8 content
233 if (ctxt->check) { in xmlCtxtCheckString()
236 "String is not UTF-8 %s", (const char *) str); in xmlCtxtCheckString()
252 if (ctxt->check) { in xmlCtxtCheckName()
263 if ((ctxt->dict != NULL) && in xmlCtxtCheckName()
264 (!xmlDictOwns(ctxt->dict, name)) && in xmlCtxtCheckName()
265 ((ctxt->doc == NULL) || in xmlCtxtCheckName()
266 ((ctxt->doc->parseFlags & (XML_PARSE_SAX1 | XML_PARSE_NODICT)) == 0))) { in xmlCtxtCheckName()
268 "Name is not from the document dictionary '%s'", in xmlCtxtCheckName()
279 doc = node->doc; in xmlCtxtGenericNodeCheck()
281 if (node->parent == NULL) in xmlCtxtGenericNodeCheck()
284 if (node->doc == NULL) { in xmlCtxtGenericNodeCheck()
289 dict = doc->dict; in xmlCtxtGenericNodeCheck()
290 if ((dict == NULL) && (ctxt->nodict == 0)) { in xmlCtxtGenericNodeCheck()
293 if (doc->type == XML_DOCUMENT_NODE) in xmlCtxtGenericNodeCheck()
295 "Document has no dictionary\n"); in xmlCtxtGenericNodeCheck()
297 ctxt->nodict = 1; in xmlCtxtGenericNodeCheck()
299 if (ctxt->doc == NULL) in xmlCtxtGenericNodeCheck()
300 ctxt->doc = doc; in xmlCtxtGenericNodeCheck()
302 if (ctxt->dict == NULL) { in xmlCtxtGenericNodeCheck()
303 ctxt->dict = dict; in xmlCtxtGenericNodeCheck()
306 if ((node->parent != NULL) && (node->doc != node->parent->doc) && in xmlCtxtGenericNodeCheck()
307 (!xmlStrEqual(node->name, BAD_CAST "pseudoroot"))) in xmlCtxtGenericNodeCheck()
310 if (node->prev == NULL) { in xmlCtxtGenericNodeCheck()
311 if (node->type == XML_ATTRIBUTE_NODE) { in xmlCtxtGenericNodeCheck()
312 if ((node->parent != NULL) && in xmlCtxtGenericNodeCheck()
313 (node != (xmlNodePtr) node->parent->properties)) in xmlCtxtGenericNodeCheck()
317 } else if ((node->parent != NULL) && (node->parent->children != node)) in xmlCtxtGenericNodeCheck()
321 if (node->prev->next != node) in xmlCtxtGenericNodeCheck()
323 "Node prev->next : back link wrong\n"); in xmlCtxtGenericNodeCheck()
325 if (node->next == NULL) { in xmlCtxtGenericNodeCheck()
326 if ((node->parent != NULL) && (node->type != XML_ATTRIBUTE_NODE) && in xmlCtxtGenericNodeCheck()
327 (node->parent->last != node) && in xmlCtxtGenericNodeCheck()
328 (node->parent->type == XML_ELEMENT_NODE)) in xmlCtxtGenericNodeCheck()
332 if (node->next->prev != node) in xmlCtxtGenericNodeCheck()
334 "Node next->prev : forward link wrong\n"); in xmlCtxtGenericNodeCheck()
335 if (node->next->parent != node->parent) in xmlCtxtGenericNodeCheck()
337 "Node next->prev : forward link wrong\n"); in xmlCtxtGenericNodeCheck()
339 if (node->type == XML_ELEMENT_NODE) { in xmlCtxtGenericNodeCheck()
342 ns = node->nsDef; in xmlCtxtGenericNodeCheck()
345 ns = ns->next; in xmlCtxtGenericNodeCheck()
347 if (node->ns != NULL) in xmlCtxtGenericNodeCheck()
348 xmlCtxtNsCheckScope(ctxt, node, node->ns); in xmlCtxtGenericNodeCheck()
349 } else if (node->type == XML_ATTRIBUTE_NODE) { in xmlCtxtGenericNodeCheck()
350 if (node->ns != NULL) in xmlCtxtGenericNodeCheck()
351 xmlCtxtNsCheckScope(ctxt, node, node->ns); in xmlCtxtGenericNodeCheck()
354 if ((node->type != XML_ELEMENT_NODE) && in xmlCtxtGenericNodeCheck()
355 (node->type != XML_ATTRIBUTE_NODE) && in xmlCtxtGenericNodeCheck()
356 (node->type != XML_ELEMENT_DECL) && in xmlCtxtGenericNodeCheck()
357 (node->type != XML_ATTRIBUTE_DECL) && in xmlCtxtGenericNodeCheck()
358 (node->type != XML_DTD_NODE) && in xmlCtxtGenericNodeCheck()
359 (node->type != XML_HTML_DOCUMENT_NODE) && in xmlCtxtGenericNodeCheck()
360 (node->type != XML_DOCUMENT_NODE)) { in xmlCtxtGenericNodeCheck()
361 if (node->content != NULL) in xmlCtxtGenericNodeCheck()
362 xmlCtxtCheckString(ctxt, (const xmlChar *) node->content); in xmlCtxtGenericNodeCheck()
364 switch (node->type) { in xmlCtxtGenericNodeCheck()
367 xmlCtxtCheckName(ctxt, node->name); in xmlCtxtGenericNodeCheck()
370 if ((node->name == xmlStringText) || in xmlCtxtGenericNodeCheck()
371 (node->name == xmlStringTextNoenc)) in xmlCtxtGenericNodeCheck()
374 if ((ctxt->dict != NULL) && in xmlCtxtGenericNodeCheck()
375 (node->name == xmlDictLookup(ctxt->dict, BAD_CAST "nbktext", in xmlCtxtGenericNodeCheck()
381 (const char *) node->name); in xmlCtxtGenericNodeCheck()
384 if (node->name == xmlStringComment) in xmlCtxtGenericNodeCheck()
388 (const char *) node->name); in xmlCtxtGenericNodeCheck()
391 xmlCtxtCheckName(ctxt, node->name); in xmlCtxtGenericNodeCheck()
394 if (node->name == NULL) in xmlCtxtGenericNodeCheck()
398 (const char *) node->name); in xmlCtxtGenericNodeCheck()
426 if (ctxt->check) { in xmlCtxtDumpString()
431 fprintf(ctxt->output, "(NULL)"); in xmlCtxtDumpString()
438 fputc(' ', ctxt->output); in xmlCtxtDumpString()
440 fprintf(ctxt->output, "#%X", str[i]); in xmlCtxtDumpString()
442 fputc(str[i], ctxt->output); in xmlCtxtDumpString()
443 fprintf(ctxt->output, "..."); in xmlCtxtDumpString()
452 if (!ctxt->check) in xmlCtxtDumpDtdNode()
453 fprintf(ctxt->output, "DTD node is NULL\n"); in xmlCtxtDumpDtdNode()
457 if (dtd->type != XML_DTD_NODE) { in xmlCtxtDumpDtdNode()
462 if (!ctxt->check) { in xmlCtxtDumpDtdNode()
463 if (dtd->name != NULL) in xmlCtxtDumpDtdNode()
464 fprintf(ctxt->output, "DTD(%s)", (char *) dtd->name); in xmlCtxtDumpDtdNode()
466 fprintf(ctxt->output, "DTD"); in xmlCtxtDumpDtdNode()
467 if (dtd->ExternalID != NULL) in xmlCtxtDumpDtdNode()
468 fprintf(ctxt->output, ", PUBLIC %s", (char *) dtd->ExternalID); in xmlCtxtDumpDtdNode()
469 if (dtd->SystemID != NULL) in xmlCtxtDumpDtdNode()
470 fprintf(ctxt->output, ", SYSTEM %s", (char *) dtd->SystemID); in xmlCtxtDumpDtdNode()
471 fprintf(ctxt->output, "\n"); in xmlCtxtDumpDtdNode()
485 if (!ctxt->check) in xmlCtxtDumpAttrDecl()
486 fprintf(ctxt->output, "Attribute declaration is NULL\n"); in xmlCtxtDumpAttrDecl()
489 if (attr->type != XML_ATTRIBUTE_DECL) { in xmlCtxtDumpAttrDecl()
494 if (attr->name != NULL) { in xmlCtxtDumpAttrDecl()
495 if (!ctxt->check) in xmlCtxtDumpAttrDecl()
496 fprintf(ctxt->output, "ATTRDECL(%s)", (char *) attr->name); in xmlCtxtDumpAttrDecl()
500 if (attr->elem != NULL) { in xmlCtxtDumpAttrDecl()
501 if (!ctxt->check) in xmlCtxtDumpAttrDecl()
502 fprintf(ctxt->output, " for %s", (char *) attr->elem); in xmlCtxtDumpAttrDecl()
506 if (!ctxt->check) { in xmlCtxtDumpAttrDecl()
507 switch (attr->atype) { in xmlCtxtDumpAttrDecl()
509 fprintf(ctxt->output, " CDATA"); in xmlCtxtDumpAttrDecl()
512 fprintf(ctxt->output, " ID"); in xmlCtxtDumpAttrDecl()
515 fprintf(ctxt->output, " IDREF"); in xmlCtxtDumpAttrDecl()
518 fprintf(ctxt->output, " IDREFS"); in xmlCtxtDumpAttrDecl()
521 fprintf(ctxt->output, " ENTITY"); in xmlCtxtDumpAttrDecl()
524 fprintf(ctxt->output, " ENTITIES"); in xmlCtxtDumpAttrDecl()
527 fprintf(ctxt->output, " NMTOKEN"); in xmlCtxtDumpAttrDecl()
530 fprintf(ctxt->output, " NMTOKENS"); in xmlCtxtDumpAttrDecl()
533 fprintf(ctxt->output, " ENUMERATION"); in xmlCtxtDumpAttrDecl()
536 fprintf(ctxt->output, " NOTATION "); in xmlCtxtDumpAttrDecl()
539 if (attr->tree != NULL) { in xmlCtxtDumpAttrDecl()
541 xmlEnumerationPtr cur = attr->tree; in xmlCtxtDumpAttrDecl()
545 fprintf(ctxt->output, "|%s", (char *) cur->name); in xmlCtxtDumpAttrDecl()
547 fprintf(ctxt->output, " (%s", (char *) cur->name); in xmlCtxtDumpAttrDecl()
548 cur = cur->next; in xmlCtxtDumpAttrDecl()
553 fprintf(ctxt->output, ")"); in xmlCtxtDumpAttrDecl()
555 fprintf(ctxt->output, "...)"); in xmlCtxtDumpAttrDecl()
557 switch (attr->def) { in xmlCtxtDumpAttrDecl()
561 fprintf(ctxt->output, " REQUIRED"); in xmlCtxtDumpAttrDecl()
564 fprintf(ctxt->output, " IMPLIED"); in xmlCtxtDumpAttrDecl()
567 fprintf(ctxt->output, " FIXED"); in xmlCtxtDumpAttrDecl()
570 if (attr->defaultValue != NULL) { in xmlCtxtDumpAttrDecl()
571 fprintf(ctxt->output, "\""); in xmlCtxtDumpAttrDecl()
572 xmlCtxtDumpString(ctxt, attr->defaultValue); in xmlCtxtDumpAttrDecl()
573 fprintf(ctxt->output, "\""); in xmlCtxtDumpAttrDecl()
575 fprintf(ctxt->output, "\n"); in xmlCtxtDumpAttrDecl()
590 if (!ctxt->check) in xmlCtxtDumpElemDecl()
591 fprintf(ctxt->output, "Element declaration is NULL\n"); in xmlCtxtDumpElemDecl()
594 if (elem->type != XML_ELEMENT_DECL) { in xmlCtxtDumpElemDecl()
599 if (elem->name != NULL) { in xmlCtxtDumpElemDecl()
600 if (!ctxt->check) { in xmlCtxtDumpElemDecl()
601 fprintf(ctxt->output, "ELEMDECL("); in xmlCtxtDumpElemDecl()
602 xmlCtxtDumpString(ctxt, elem->name); in xmlCtxtDumpElemDecl()
603 fprintf(ctxt->output, ")"); in xmlCtxtDumpElemDecl()
608 if (!ctxt->check) { in xmlCtxtDumpElemDecl()
609 switch (elem->etype) { in xmlCtxtDumpElemDecl()
611 fprintf(ctxt->output, ", UNDEFINED"); in xmlCtxtDumpElemDecl()
614 fprintf(ctxt->output, ", EMPTY"); in xmlCtxtDumpElemDecl()
617 fprintf(ctxt->output, ", ANY"); in xmlCtxtDumpElemDecl()
620 fprintf(ctxt->output, ", MIXED "); in xmlCtxtDumpElemDecl()
623 fprintf(ctxt->output, ", MIXED "); in xmlCtxtDumpElemDecl()
626 if ((elem->type != XML_ELEMENT_NODE) && (elem->content != NULL)) { in xmlCtxtDumpElemDecl()
630 xmlSnprintfElementContent(buf, 5000, elem->content, 1); in xmlCtxtDumpElemDecl()
632 fprintf(ctxt->output, "%s", buf); in xmlCtxtDumpElemDecl()
634 fprintf(ctxt->output, "\n"); in xmlCtxtDumpElemDecl()
649 if (!ctxt->check) in xmlCtxtDumpEntityDecl()
650 fprintf(ctxt->output, "Entity declaration is NULL\n"); in xmlCtxtDumpEntityDecl()
653 if (ent->type != XML_ENTITY_DECL) { in xmlCtxtDumpEntityDecl()
658 if (ent->name != NULL) { in xmlCtxtDumpEntityDecl()
659 if (!ctxt->check) { in xmlCtxtDumpEntityDecl()
660 fprintf(ctxt->output, "ENTITYDECL("); in xmlCtxtDumpEntityDecl()
661 xmlCtxtDumpString(ctxt, ent->name); in xmlCtxtDumpEntityDecl()
662 fprintf(ctxt->output, ")"); in xmlCtxtDumpEntityDecl()
667 if (!ctxt->check) { in xmlCtxtDumpEntityDecl()
668 switch (ent->etype) { in xmlCtxtDumpEntityDecl()
670 fprintf(ctxt->output, ", internal\n"); in xmlCtxtDumpEntityDecl()
673 fprintf(ctxt->output, ", external parsed\n"); in xmlCtxtDumpEntityDecl()
676 fprintf(ctxt->output, ", unparsed\n"); in xmlCtxtDumpEntityDecl()
679 fprintf(ctxt->output, ", parameter\n"); in xmlCtxtDumpEntityDecl()
682 fprintf(ctxt->output, ", external parameter\n"); in xmlCtxtDumpEntityDecl()
685 fprintf(ctxt->output, ", predefined\n"); in xmlCtxtDumpEntityDecl()
688 if (ent->ExternalID) { in xmlCtxtDumpEntityDecl()
690 fprintf(ctxt->output, " ExternalID=%s\n", in xmlCtxtDumpEntityDecl()
691 (char *) ent->ExternalID); in xmlCtxtDumpEntityDecl()
693 if (ent->SystemID) { in xmlCtxtDumpEntityDecl()
695 fprintf(ctxt->output, " SystemID=%s\n", in xmlCtxtDumpEntityDecl()
696 (char *) ent->SystemID); in xmlCtxtDumpEntityDecl()
698 if (ent->URI != NULL) { in xmlCtxtDumpEntityDecl()
700 fprintf(ctxt->output, " URI=%s\n", (char *) ent->URI); in xmlCtxtDumpEntityDecl()
702 if (ent->content) { in xmlCtxtDumpEntityDecl()
704 fprintf(ctxt->output, " content="); in xmlCtxtDumpEntityDecl()
705 xmlCtxtDumpString(ctxt, ent->content); in xmlCtxtDumpEntityDecl()
706 fprintf(ctxt->output, "\n"); in xmlCtxtDumpEntityDecl()
722 if (!ctxt->check) in xmlCtxtDumpNamespace()
723 fprintf(ctxt->output, "namespace node is NULL\n"); in xmlCtxtDumpNamespace()
726 if (ns->type != XML_NAMESPACE_DECL) { in xmlCtxtDumpNamespace()
731 if (ns->href == NULL) { in xmlCtxtDumpNamespace()
732 if (ns->prefix != NULL) in xmlCtxtDumpNamespace()
735 (char *) ns->prefix); in xmlCtxtDumpNamespace()
740 if (!ctxt->check) { in xmlCtxtDumpNamespace()
741 if (ns->prefix != NULL) in xmlCtxtDumpNamespace()
742 fprintf(ctxt->output, "namespace %s href=", in xmlCtxtDumpNamespace()
743 (char *) ns->prefix); in xmlCtxtDumpNamespace()
745 fprintf(ctxt->output, "default namespace href="); in xmlCtxtDumpNamespace()
747 xmlCtxtDumpString(ctxt, ns->href); in xmlCtxtDumpNamespace()
748 fprintf(ctxt->output, "\n"); in xmlCtxtDumpNamespace()
758 ns = ns->next; in xmlCtxtDumpNamespaceList()
768 if (!ctxt->check) in xmlCtxtDumpEntity()
769 fprintf(ctxt->output, "Entity is NULL\n"); in xmlCtxtDumpEntity()
772 if (!ctxt->check) { in xmlCtxtDumpEntity()
773 switch (ent->etype) { in xmlCtxtDumpEntity()
775 fprintf(ctxt->output, "INTERNAL_GENERAL_ENTITY "); in xmlCtxtDumpEntity()
778 fprintf(ctxt->output, "EXTERNAL_GENERAL_PARSED_ENTITY "); in xmlCtxtDumpEntity()
781 fprintf(ctxt->output, "EXTERNAL_GENERAL_UNPARSED_ENTITY "); in xmlCtxtDumpEntity()
784 fprintf(ctxt->output, "INTERNAL_PARAMETER_ENTITY "); in xmlCtxtDumpEntity()
787 fprintf(ctxt->output, "EXTERNAL_PARAMETER_ENTITY "); in xmlCtxtDumpEntity()
790 fprintf(ctxt->output, "ENTITY_%d ! ", (int) ent->etype); in xmlCtxtDumpEntity()
792 fprintf(ctxt->output, "%s\n", ent->name); in xmlCtxtDumpEntity()
793 if (ent->ExternalID) { in xmlCtxtDumpEntity()
795 fprintf(ctxt->output, "ExternalID=%s\n", in xmlCtxtDumpEntity()
796 (char *) ent->ExternalID); in xmlCtxtDumpEntity()
798 if (ent->SystemID) { in xmlCtxtDumpEntity()
800 fprintf(ctxt->output, "SystemID=%s\n", (char *) ent->SystemID); in xmlCtxtDumpEntity()
802 if (ent->URI) { in xmlCtxtDumpEntity()
804 fprintf(ctxt->output, "URI=%s\n", (char *) ent->URI); in xmlCtxtDumpEntity()
806 if (ent->content) { in xmlCtxtDumpEntity()
808 fprintf(ctxt->output, "content="); in xmlCtxtDumpEntity()
809 xmlCtxtDumpString(ctxt, ent->content); in xmlCtxtDumpEntity()
810 fprintf(ctxt->output, "\n"); in xmlCtxtDumpEntity()
817 * @output: the FILE * for the output
829 if (!ctxt->check) in xmlCtxtDumpAttr()
830 fprintf(ctxt->output, "Attr is NULL"); in xmlCtxtDumpAttr()
833 if (!ctxt->check) { in xmlCtxtDumpAttr()
834 fprintf(ctxt->output, "ATTRIBUTE "); in xmlCtxtDumpAttr()
835 xmlCtxtDumpString(ctxt, attr->name); in xmlCtxtDumpAttr()
836 fprintf(ctxt->output, "\n"); in xmlCtxtDumpAttr()
837 if (attr->children != NULL) { in xmlCtxtDumpAttr()
838 ctxt->depth++; in xmlCtxtDumpAttr()
839 xmlCtxtDumpNodeList(ctxt, attr->children); in xmlCtxtDumpAttr()
840 ctxt->depth--; in xmlCtxtDumpAttr()
843 if (attr->name == NULL) in xmlCtxtDumpAttr()
855 * @output: the FILE * for the output
866 attr = attr->next; in xmlCtxtDumpAttrList()
872 * @output: the FILE * for the output
882 if (!ctxt->check) { in xmlCtxtDumpOneNode()
884 fprintf(ctxt->output, "node is NULL\n"); in xmlCtxtDumpOneNode()
888 ctxt->node = node; in xmlCtxtDumpOneNode()
890 switch (node->type) { in xmlCtxtDumpOneNode()
892 if (!ctxt->check) { in xmlCtxtDumpOneNode()
894 fprintf(ctxt->output, "ELEMENT "); in xmlCtxtDumpOneNode()
895 if ((node->ns != NULL) && (node->ns->prefix != NULL)) { in xmlCtxtDumpOneNode()
896 xmlCtxtDumpString(ctxt, node->ns->prefix); in xmlCtxtDumpOneNode()
897 fprintf(ctxt->output, ":"); in xmlCtxtDumpOneNode()
899 xmlCtxtDumpString(ctxt, node->name); in xmlCtxtDumpOneNode()
900 fprintf(ctxt->output, "\n"); in xmlCtxtDumpOneNode()
904 if (!ctxt->check) in xmlCtxtDumpOneNode()
906 fprintf(ctxt->output, "Error, ATTRIBUTE found here\n"); in xmlCtxtDumpOneNode()
910 if (!ctxt->check) { in xmlCtxtDumpOneNode()
912 if (node->name == (const xmlChar *) xmlStringTextNoenc) in xmlCtxtDumpOneNode()
913 fprintf(ctxt->output, "TEXT no enc"); in xmlCtxtDumpOneNode()
915 fprintf(ctxt->output, "TEXT"); in xmlCtxtDumpOneNode()
916 if (ctxt->options & DUMP_TEXT_TYPE) { in xmlCtxtDumpOneNode()
917 if (node->content == (xmlChar *) &(node->properties)) in xmlCtxtDumpOneNode()
918 fprintf(ctxt->output, " compact\n"); in xmlCtxtDumpOneNode()
919 else if (xmlDictOwns(ctxt->dict, node->content) == 1) in xmlCtxtDumpOneNode()
920 fprintf(ctxt->output, " interned\n"); in xmlCtxtDumpOneNode()
922 fprintf(ctxt->output, "\n"); in xmlCtxtDumpOneNode()
924 fprintf(ctxt->output, "\n"); in xmlCtxtDumpOneNode()
928 if (!ctxt->check) { in xmlCtxtDumpOneNode()
930 fprintf(ctxt->output, "CDATA_SECTION\n"); in xmlCtxtDumpOneNode()
934 if (!ctxt->check) { in xmlCtxtDumpOneNode()
936 fprintf(ctxt->output, "ENTITY_REF(%s)\n", in xmlCtxtDumpOneNode()
937 (char *) node->name); in xmlCtxtDumpOneNode()
941 if (!ctxt->check) { in xmlCtxtDumpOneNode()
943 fprintf(ctxt->output, "ENTITY\n"); in xmlCtxtDumpOneNode()
947 if (!ctxt->check) { in xmlCtxtDumpOneNode()
949 fprintf(ctxt->output, "PI %s\n", (char *) node->name); in xmlCtxtDumpOneNode()
953 if (!ctxt->check) { in xmlCtxtDumpOneNode()
955 fprintf(ctxt->output, "COMMENT\n"); in xmlCtxtDumpOneNode()
960 if (!ctxt->check) { in xmlCtxtDumpOneNode()
963 fprintf(ctxt->output, "Error, DOCUMENT found here\n"); in xmlCtxtDumpOneNode()
967 if (!ctxt->check) { in xmlCtxtDumpOneNode()
969 fprintf(ctxt->output, "DOCUMENT_TYPE\n"); in xmlCtxtDumpOneNode()
973 if (!ctxt->check) { in xmlCtxtDumpOneNode()
975 fprintf(ctxt->output, "DOCUMENT_FRAG\n"); in xmlCtxtDumpOneNode()
979 if (!ctxt->check) { in xmlCtxtDumpOneNode()
981 fprintf(ctxt->output, "NOTATION\n"); in xmlCtxtDumpOneNode()
1000 if (!ctxt->check) { in xmlCtxtDumpOneNode()
1002 fprintf(ctxt->output, "INCLUDE START\n"); in xmlCtxtDumpOneNode()
1006 if (!ctxt->check) { in xmlCtxtDumpOneNode()
1008 fprintf(ctxt->output, "INCLUDE END\n"); in xmlCtxtDumpOneNode()
1012 if (!ctxt->check) in xmlCtxtDumpOneNode()
1015 "Unknown node type %d\n", node->type); in xmlCtxtDumpOneNode()
1018 if (node->doc == NULL) { in xmlCtxtDumpOneNode()
1019 if (!ctxt->check) { in xmlCtxtDumpOneNode()
1022 fprintf(ctxt->output, "PBM: doc == NULL !!!\n"); in xmlCtxtDumpOneNode()
1024 ctxt->depth++; in xmlCtxtDumpOneNode()
1025 if ((node->type == XML_ELEMENT_NODE) && (node->nsDef != NULL)) in xmlCtxtDumpOneNode()
1026 xmlCtxtDumpNamespaceList(ctxt, node->nsDef); in xmlCtxtDumpOneNode()
1027 if ((node->type == XML_ELEMENT_NODE) && (node->properties != NULL)) in xmlCtxtDumpOneNode()
1028 xmlCtxtDumpAttrList(ctxt, node->properties); in xmlCtxtDumpOneNode()
1029 if (node->type != XML_ENTITY_REF_NODE) { in xmlCtxtDumpOneNode()
1030 if ((node->type != XML_ELEMENT_NODE) && (node->content != NULL)) { in xmlCtxtDumpOneNode()
1031 if (!ctxt->check) { in xmlCtxtDumpOneNode()
1033 fprintf(ctxt->output, "content="); in xmlCtxtDumpOneNode()
1034 xmlCtxtDumpString(ctxt, node->content); in xmlCtxtDumpOneNode()
1035 fprintf(ctxt->output, "\n"); in xmlCtxtDumpOneNode()
1041 ent = xmlGetDocEntity(node->doc, node->name); in xmlCtxtDumpOneNode()
1045 ctxt->depth--; in xmlCtxtDumpOneNode()
1055 * @output: the FILE * for the output
1065 if (!ctxt->check) { in xmlCtxtDumpNode()
1067 fprintf(ctxt->output, "node is NULL\n"); in xmlCtxtDumpNode()
1072 if ((node->type != XML_NAMESPACE_DECL) && in xmlCtxtDumpNode()
1073 (node->children != NULL) && (node->type != XML_ENTITY_REF_NODE)) { in xmlCtxtDumpNode()
1074 ctxt->depth++; in xmlCtxtDumpNode()
1075 xmlCtxtDumpNodeList(ctxt, node->children); in xmlCtxtDumpNode()
1076 ctxt->depth--; in xmlCtxtDumpNode()
1082 * @output: the FILE * for the output
1093 node = node->next; in xmlCtxtDumpNodeList()
1101 if (!ctxt->check) in xmlCtxtDumpDocHead()
1102 fprintf(ctxt->output, "DOCUMENT == NULL !\n"); in xmlCtxtDumpDocHead()
1105 ctxt->node = (xmlNodePtr) doc; in xmlCtxtDumpDocHead()
1107 switch (doc->type) { in xmlCtxtDumpDocHead()
1141 if (!ctxt->check) in xmlCtxtDumpDocHead()
1142 fprintf(ctxt->output, "DOCUMENT\n"); in xmlCtxtDumpDocHead()
1145 if (!ctxt->check) in xmlCtxtDumpDocHead()
1146 fprintf(ctxt->output, "HTML DOCUMENT\n"); in xmlCtxtDumpDocHead()
1162 "Unknown node type %d\n", doc->type); in xmlCtxtDumpDocHead()
1168 * @output: the FILE * for the output
1169 * @doc: the document
1171 * Dumps debug information cncerning the document, not recursive
1178 if (!ctxt->check) { in xmlCtxtDumpDocumentHead()
1179 if (doc->name != NULL) { in xmlCtxtDumpDocumentHead()
1180 fprintf(ctxt->output, "name="); in xmlCtxtDumpDocumentHead()
1181 xmlCtxtDumpString(ctxt, BAD_CAST doc->name); in xmlCtxtDumpDocumentHead()
1182 fprintf(ctxt->output, "\n"); in xmlCtxtDumpDocumentHead()
1184 if (doc->version != NULL) { in xmlCtxtDumpDocumentHead()
1185 fprintf(ctxt->output, "version="); in xmlCtxtDumpDocumentHead()
1186 xmlCtxtDumpString(ctxt, doc->version); in xmlCtxtDumpDocumentHead()
1187 fprintf(ctxt->output, "\n"); in xmlCtxtDumpDocumentHead()
1189 if (doc->encoding != NULL) { in xmlCtxtDumpDocumentHead()
1190 fprintf(ctxt->output, "encoding="); in xmlCtxtDumpDocumentHead()
1191 xmlCtxtDumpString(ctxt, doc->encoding); in xmlCtxtDumpDocumentHead()
1192 fprintf(ctxt->output, "\n"); in xmlCtxtDumpDocumentHead()
1194 if (doc->URL != NULL) { in xmlCtxtDumpDocumentHead()
1195 fprintf(ctxt->output, "URL="); in xmlCtxtDumpDocumentHead()
1196 xmlCtxtDumpString(ctxt, doc->URL); in xmlCtxtDumpDocumentHead()
1197 fprintf(ctxt->output, "\n"); in xmlCtxtDumpDocumentHead()
1199 if (doc->standalone) in xmlCtxtDumpDocumentHead()
1200 fprintf(ctxt->output, "standalone=true\n"); in xmlCtxtDumpDocumentHead()
1202 if (doc->oldNs != NULL) in xmlCtxtDumpDocumentHead()
1203 xmlCtxtDumpNamespaceList(ctxt, doc->oldNs); in xmlCtxtDumpDocumentHead()
1208 * @output: the FILE * for the output
1209 * @doc: the document
1211 * Dumps debug information for the document, it's recursive
1217 if (!ctxt->check) in xmlCtxtDumpDocument()
1218 fprintf(ctxt->output, "DOCUMENT == NULL !\n"); in xmlCtxtDumpDocument()
1222 if (((doc->type == XML_DOCUMENT_NODE) || in xmlCtxtDumpDocument()
1223 (doc->type == XML_HTML_DOCUMENT_NODE)) in xmlCtxtDumpDocument()
1224 && (doc->children != NULL)) { in xmlCtxtDumpDocument()
1225 ctxt->depth++; in xmlCtxtDumpDocument()
1226 xmlCtxtDumpNodeList(ctxt, doc->children); in xmlCtxtDumpDocument()
1227 ctxt->depth--; in xmlCtxtDumpDocument()
1238 if (!ctxt->check) in xmlCtxtDumpEntityCallback()
1239 fprintf(ctxt->output, "Entity is NULL"); in xmlCtxtDumpEntityCallback()
1242 if (!ctxt->check) { in xmlCtxtDumpEntityCallback()
1243 fprintf(ctxt->output, "%s : ", (char *) cur->name); in xmlCtxtDumpEntityCallback()
1244 switch (cur->etype) { in xmlCtxtDumpEntityCallback()
1246 fprintf(ctxt->output, "INTERNAL GENERAL, "); in xmlCtxtDumpEntityCallback()
1249 fprintf(ctxt->output, "EXTERNAL PARSED, "); in xmlCtxtDumpEntityCallback()
1252 fprintf(ctxt->output, "EXTERNAL UNPARSED, "); in xmlCtxtDumpEntityCallback()
1255 fprintf(ctxt->output, "INTERNAL PARAMETER, "); in xmlCtxtDumpEntityCallback()
1258 fprintf(ctxt->output, "EXTERNAL PARAMETER, "); in xmlCtxtDumpEntityCallback()
1262 "Unknown entity type %d\n", cur->etype); in xmlCtxtDumpEntityCallback()
1264 if (cur->ExternalID != NULL) in xmlCtxtDumpEntityCallback()
1265 fprintf(ctxt->output, "ID \"%s\"", (char *) cur->ExternalID); in xmlCtxtDumpEntityCallback()
1266 if (cur->SystemID != NULL) in xmlCtxtDumpEntityCallback()
1267 fprintf(ctxt->output, "SYSTEM \"%s\"", (char *) cur->SystemID); in xmlCtxtDumpEntityCallback()
1268 if (cur->orig != NULL) in xmlCtxtDumpEntityCallback()
1269 fprintf(ctxt->output, "\n orig \"%s\"", (char *) cur->orig); in xmlCtxtDumpEntityCallback()
1270 if ((cur->type != XML_ELEMENT_NODE) && (cur->content != NULL)) in xmlCtxtDumpEntityCallback()
1271 fprintf(ctxt->output, "\n content \"%s\"", in xmlCtxtDumpEntityCallback()
1272 (char *) cur->content); in xmlCtxtDumpEntityCallback()
1273 fprintf(ctxt->output, "\n"); in xmlCtxtDumpEntityCallback()
1279 * @output: the FILE * for the output
1280 * @doc: the document
1282 * Dumps debug information for all the entities in use by the document
1289 if ((doc->intSubset != NULL) && (doc->intSubset->entities != NULL)) { in xmlCtxtDumpEntities()
1291 doc->intSubset->entities; in xmlCtxtDumpEntities()
1293 if (!ctxt->check) in xmlCtxtDumpEntities()
1294 fprintf(ctxt->output, "Entities in internal subset\n"); in xmlCtxtDumpEntities()
1297 fprintf(ctxt->output, "No entities in internal subset\n"); in xmlCtxtDumpEntities()
1298 if ((doc->extSubset != NULL) && (doc->extSubset->entities != NULL)) { in xmlCtxtDumpEntities()
1300 doc->extSubset->entities; in xmlCtxtDumpEntities()
1302 if (!ctxt->check) in xmlCtxtDumpEntities()
1303 fprintf(ctxt->output, "Entities in external subset\n"); in xmlCtxtDumpEntities()
1305 } else if (!ctxt->check) in xmlCtxtDumpEntities()
1306 fprintf(ctxt->output, "No entities in external subset\n"); in xmlCtxtDumpEntities()
1311 * @output: the FILE * for the output
1320 if (!ctxt->check) in xmlCtxtDumpDTD()
1321 fprintf(ctxt->output, "DTD is NULL\n"); in xmlCtxtDumpDTD()
1325 if (dtd->children == NULL) in xmlCtxtDumpDTD()
1326 fprintf(ctxt->output, " DTD is empty\n"); in xmlCtxtDumpDTD()
1328 ctxt->depth++; in xmlCtxtDumpDTD()
1329 xmlCtxtDumpNodeList(ctxt, dtd->children); in xmlCtxtDumpDTD()
1330 ctxt->depth--; in xmlCtxtDumpDTD()
1342 * @output: the FILE * for the output
1348 xmlDebugDumpString(FILE * output, const xmlChar * str) in xmlDebugDumpString() argument
1352 if (output == NULL) in xmlDebugDumpString()
1353 output = stdout; in xmlDebugDumpString()
1355 fprintf(output, "(NULL)"); in xmlDebugDumpString()
1362 fputc(' ', output); in xmlDebugDumpString()
1364 fprintf(output, "#%X", str[i]); in xmlDebugDumpString()
1366 fputc(str[i], output); in xmlDebugDumpString()
1367 fprintf(output, "..."); in xmlDebugDumpString()
1372 * @output: the FILE * for the output
1379 xmlDebugDumpAttr(FILE *output, xmlAttrPtr attr, int depth) { in xmlDebugDumpAttr() argument
1382 if (output == NULL) return; in xmlDebugDumpAttr()
1384 ctxt.output = output; in xmlDebugDumpAttr()
1393 * @output: the FILE * for the output
1394 * @doc: the document
1396 * Dumps debug information for all the entities in use by the document
1399 xmlDebugDumpEntities(FILE * output, xmlDocPtr doc) in xmlDebugDumpEntities() argument
1403 if (output == NULL) return; in xmlDebugDumpEntities()
1405 ctxt.output = output; in xmlDebugDumpEntities()
1412 * @output: the FILE * for the output
1419 xmlDebugDumpAttrList(FILE * output, xmlAttrPtr attr, int depth) in xmlDebugDumpAttrList() argument
1423 if (output == NULL) return; in xmlDebugDumpAttrList()
1425 ctxt.output = output; in xmlDebugDumpAttrList()
1433 * @output: the FILE * for the output
1440 xmlDebugDumpOneNode(FILE * output, xmlNodePtr node, int depth) in xmlDebugDumpOneNode() argument
1444 if (output == NULL) return; in xmlDebugDumpOneNode()
1446 ctxt.output = output; in xmlDebugDumpOneNode()
1454 * @output: the FILE * for the output
1461 xmlDebugDumpNode(FILE * output, xmlNodePtr node, int depth) in xmlDebugDumpNode() argument
1465 if (output == NULL) in xmlDebugDumpNode()
1466 output = stdout; in xmlDebugDumpNode()
1468 ctxt.output = output; in xmlDebugDumpNode()
1476 * @output: the FILE * for the output
1483 xmlDebugDumpNodeList(FILE * output, xmlNodePtr node, int depth) in xmlDebugDumpNodeList() argument
1487 if (output == NULL) in xmlDebugDumpNodeList()
1488 output = stdout; in xmlDebugDumpNodeList()
1490 ctxt.output = output; in xmlDebugDumpNodeList()
1498 * @output: the FILE * for the output
1499 * @doc: the document
1501 * Dumps debug information cncerning the document, not recursive
1504 xmlDebugDumpDocumentHead(FILE * output, xmlDocPtr doc) in xmlDebugDumpDocumentHead() argument
1508 if (output == NULL) in xmlDebugDumpDocumentHead()
1509 output = stdout; in xmlDebugDumpDocumentHead()
1512 ctxt.output = output; in xmlDebugDumpDocumentHead()
1519 * @output: the FILE * for the output
1520 * @doc: the document
1522 * Dumps debug information for the document, it's recursive
1525 xmlDebugDumpDocument(FILE * output, xmlDocPtr doc) in xmlDebugDumpDocument() argument
1529 if (output == NULL) in xmlDebugDumpDocument()
1530 output = stdout; in xmlDebugDumpDocument()
1533 ctxt.output = output; in xmlDebugDumpDocument()
1540 * @output: the FILE * for the output
1546 xmlDebugDumpDTD(FILE * output, xmlDtdPtr dtd) in xmlDebugDumpDTD() argument
1550 if (output == NULL) in xmlDebugDumpDTD()
1551 output = stdout; in xmlDebugDumpDTD()
1554 ctxt.output = output; in xmlDebugDumpDTD()
1567 * @output: the FILE * for the output
1568 * @doc: the document
1570 * Check the document for potential content problems, and output
1571 * the errors to @output
1576 xmlDebugCheckDocument(FILE * output, xmlDocPtr doc) in xmlDebugCheckDocument() argument
1580 if (output == NULL) in xmlDebugCheckDocument()
1581 output = stdout; in xmlDebugCheckDocument()
1583 ctxt.output = output; in xmlDebugCheckDocument()
1612 switch (node->type) { in xmlLsCountNode()
1614 list = node->children; in xmlLsCountNode()
1621 list = ((xmlDocPtr) node)->children; in xmlLsCountNode()
1624 list = ((xmlAttrPtr) node)->children; in xmlLsCountNode()
1630 if (node->content != NULL) { in xmlLsCountNode()
1631 ret = xmlStrlen(node->content); in xmlLsCountNode()
1650 list = list->next; in xmlLsCountNode()
1656 * @output: the FILE * for the output
1659 * Dump to @output the type and name of @node.
1662 xmlLsOneNode(FILE *output, xmlNodePtr node) { in xmlLsOneNode() argument
1663 if (output == NULL) return; in xmlLsOneNode()
1665 fprintf(output, "NULL\n"); in xmlLsOneNode()
1668 switch (node->type) { in xmlLsOneNode()
1670 fprintf(output, "-"); in xmlLsOneNode()
1673 fprintf(output, "a"); in xmlLsOneNode()
1676 fprintf(output, "t"); in xmlLsOneNode()
1679 fprintf(output, "C"); in xmlLsOneNode()
1682 fprintf(output, "e"); in xmlLsOneNode()
1685 fprintf(output, "E"); in xmlLsOneNode()
1688 fprintf(output, "p"); in xmlLsOneNode()
1691 fprintf(output, "c"); in xmlLsOneNode()
1694 fprintf(output, "d"); in xmlLsOneNode()
1697 fprintf(output, "h"); in xmlLsOneNode()
1700 fprintf(output, "T"); in xmlLsOneNode()
1703 fprintf(output, "F"); in xmlLsOneNode()
1706 fprintf(output, "N"); in xmlLsOneNode()
1709 fprintf(output, "n"); in xmlLsOneNode()
1712 fprintf(output, "?"); in xmlLsOneNode()
1714 if (node->type != XML_NAMESPACE_DECL) { in xmlLsOneNode()
1715 if (node->properties != NULL) in xmlLsOneNode()
1716 fprintf(output, "a"); in xmlLsOneNode()
1718 fprintf(output, "-"); in xmlLsOneNode()
1719 if (node->nsDef != NULL) in xmlLsOneNode()
1720 fprintf(output, "n"); in xmlLsOneNode()
1722 fprintf(output, "-"); in xmlLsOneNode()
1725 fprintf(output, " %8d ", xmlLsCountNode(node)); in xmlLsOneNode()
1727 switch (node->type) { in xmlLsOneNode()
1729 if (node->name != NULL) { in xmlLsOneNode()
1730 if ((node->ns != NULL) && (node->ns->prefix != NULL)) in xmlLsOneNode()
1731 fprintf(output, "%s:", node->ns->prefix); in xmlLsOneNode()
1732 fprintf(output, "%s", (const char *) node->name); in xmlLsOneNode()
1736 if (node->name != NULL) in xmlLsOneNode()
1737 fprintf(output, "%s", (const char *) node->name); in xmlLsOneNode()
1740 if (node->content != NULL) { in xmlLsOneNode()
1741 xmlDebugDumpString(output, node->content); in xmlLsOneNode()
1747 if (node->name != NULL) in xmlLsOneNode()
1748 fprintf(output, "%s", (const char *) node->name); in xmlLsOneNode()
1751 if (node->name != NULL) in xmlLsOneNode()
1752 fprintf(output, "%s", (const char *) node->name); in xmlLsOneNode()
1755 if (node->name != NULL) in xmlLsOneNode()
1756 fprintf(output, "%s", (const char *) node->name); in xmlLsOneNode()
1773 if (ns->prefix == NULL) in xmlLsOneNode()
1774 fprintf(output, "default -> %s", (char *)ns->href); in xmlLsOneNode()
1776 fprintf(output, "%s -> %s", (char *)ns->prefix, in xmlLsOneNode()
1777 (char *)ns->href); in xmlLsOneNode()
1781 if (node->name != NULL) in xmlLsOneNode()
1782 fprintf(output, "%s", (const char *) node->name); in xmlLsOneNode()
1784 fprintf(output, "\n"); in xmlLsOneNode()
1815 * - allow to shell out an editor on a subpart
1816 * - cleanup function registrations (with help) and calling
1817 * - provide registration routines
1867 "%s is user-defined\n", arg); in xmlShellPrintXPathError()
1885 * @ctxt : a non-null shell context
1886 * @node : a non-null node to print to the output FILE
1888 * Print node to the output FILE
1900 fp = ctxt->output; in xmlShellPrintNodeCtxt()
1902 if (node->type == XML_DOCUMENT_NODE) in xmlShellPrintNodeCtxt()
1904 else if (node->type == XML_ATTRIBUTE_NODE) in xmlShellPrintNodeCtxt()
1907 xmlElemDump(fp, node->doc, node); in xmlShellPrintNodeCtxt()
1914 * @node : a non-null node to print to the output FILE
1916 * Print node to the output FILE
1930 * Prints result to the output FILE
1939 switch (list->type) { in xmlShellPrintXPathResultCtxt()
1944 if (list->nodesetval) { in xmlShellPrintXPathResultCtxt()
1945 for (indx = 0; indx < list->nodesetval->nodeNr; in xmlShellPrintXPathResultCtxt()
1948 list->nodesetval->nodeTab[indx]); in xmlShellPrintXPathResultCtxt()
1963 xmlBoolToText(list->boolval)); in xmlShellPrintXPathResultCtxt()
1967 "Is a number:%0g\n", list->floatval); in xmlShellPrintXPathResultCtxt()
1971 "Is a string:%s\n", list->stringval); in xmlShellPrintXPathResultCtxt()
1975 xmlShellPrintXPathError(list->type, NULL); in xmlShellPrintXPathResultCtxt()
1984 * Prints result to the output FILE
2013 fprintf(ctxt->output, "NULL\n"); in xmlShellList()
2016 if ((node->type == XML_DOCUMENT_NODE) || in xmlShellList()
2017 (node->type == XML_HTML_DOCUMENT_NODE)) { in xmlShellList()
2018 cur = ((xmlDocPtr) node)->children; in xmlShellList()
2019 } else if (node->type == XML_NAMESPACE_DECL) { in xmlShellList()
2020 xmlLsOneNode(ctxt->output, node); in xmlShellList()
2022 } else if (node->children != NULL) { in xmlShellList()
2023 cur = node->children; in xmlShellList()
2025 xmlLsOneNode(ctxt->output, node); in xmlShellList()
2029 xmlLsOneNode(ctxt->output, cur); in xmlShellList()
2030 cur = cur->next; in xmlShellList()
2056 fprintf(ctxt->output, "NULL\n"); in xmlShellBase()
2060 base = xmlNodeGetBase(node->doc, node); in xmlShellBase()
2063 fprintf(ctxt->output, " No base found !!!\n"); in xmlShellBase()
2065 fprintf(ctxt->output, "%s\n", base); in xmlShellBase()
2128 fprintf(ctxt->output, "setns: prefix=[nsuri] required\n"); in xmlShellRegisterNamespace()
2130 return(-1); in xmlShellRegisterNamespace()
2142 if(xmlXPathRegisterNs(ctxt->pctxt, prefix, href) != 0) { in xmlShellRegisterNamespace()
2143 …fprintf(ctxt->output,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", prefix, … in xmlShellRegisterNamespace()
2145 return(-1); in xmlShellRegisterNamespace()
2170 if ((root == NULL) || (root->type != XML_ELEMENT_NODE) || in xmlShellRegisterRootNamespaces()
2171 (root->nsDef == NULL) || (ctxt == NULL) || (ctxt->pctxt == NULL)) in xmlShellRegisterRootNamespaces()
2172 return(-1); in xmlShellRegisterRootNamespaces()
2173 ns = root->nsDef; in xmlShellRegisterRootNamespaces()
2175 if (ns->prefix == NULL) in xmlShellRegisterRootNamespaces()
2176 xmlXPathRegisterNs(ctxt->pctxt, BAD_CAST "defaultns", ns->href); in xmlShellRegisterRootNamespaces()
2178 xmlXPathRegisterNs(ctxt->pctxt, ns->prefix, ns->href); in xmlShellRegisterRootNamespaces()
2179 ns = ns->next; in xmlShellRegisterRootNamespaces()
2215 if (node->type == XML_COMMENT_NODE) { in xmlShellGrep()
2216 if (xmlStrstr(node->content, (xmlChar *) arg)) { in xmlShellGrep()
2218 fprintf(ctxt->output, "%s : ", xmlGetNodePath(node)); in xmlShellGrep()
2221 } else if (node->type == XML_TEXT_NODE) { in xmlShellGrep()
2222 if (xmlStrstr(node->content, (xmlChar *) arg)) { in xmlShellGrep()
2224 fprintf(ctxt->output, "%s : ", xmlGetNodePath(node->parent)); in xmlShellGrep()
2225 xmlShellList(ctxt, NULL, node->parent, NULL); in xmlShellGrep()
2233 if ((node->type == XML_DOCUMENT_NODE) || in xmlShellGrep()
2234 (node->type == XML_HTML_DOCUMENT_NODE)) { in xmlShellGrep()
2235 node = ((xmlDocPtr) node)->children; in xmlShellGrep()
2236 } else if ((node->children != NULL) in xmlShellGrep()
2237 && (node->type != XML_ENTITY_REF_NODE)) { in xmlShellGrep()
2239 node = node->children; in xmlShellGrep()
2240 } else if (node->next != NULL) { in xmlShellGrep()
2242 node = node->next; in xmlShellGrep()
2244 /* go up to parents->next if needed */ in xmlShellGrep()
2246 if (node->parent != NULL) { in xmlShellGrep()
2247 node = node->parent; in xmlShellGrep()
2249 if (node->next != NULL) { in xmlShellGrep()
2250 node = node->next; in xmlShellGrep()
2253 if (node->parent == NULL) { in xmlShellGrep()
2283 fprintf(ctxt->output, "NULL\n"); in xmlShellDir()
2286 if ((node->type == XML_DOCUMENT_NODE) || in xmlShellDir()
2287 (node->type == XML_HTML_DOCUMENT_NODE)) { in xmlShellDir()
2288 xmlDebugDumpDocumentHead(ctxt->output, (xmlDocPtr) node); in xmlShellDir()
2289 } else if (node->type == XML_ATTRIBUTE_NODE) { in xmlShellDir()
2290 xmlDebugDumpAttr(ctxt->output, (xmlAttrPtr) node, 0); in xmlShellDir()
2292 xmlDebugDumpOneNode(ctxt->output, node, 0); in xmlShellDir()
2320 fprintf(ctxt->output, "NULL\n"); in xmlShellSetContent()
2324 fprintf(ctxt->output, "NULL\n"); in xmlShellSetContent()
2330 if (node->children != NULL) { in xmlShellSetContent()
2331 xmlFreeNodeList(node->children); in xmlShellSetContent()
2332 node->children = NULL; in xmlShellSetContent()
2333 node->last = NULL; in xmlShellSetContent()
2337 fprintf(ctxt->output, "failed to parse content\n"); in xmlShellSetContent()
2346 * @schemas: the path to the Relax-NG schemas
2351 * validating the instance against a Relax-NG schemas
2374 "Relax-NG schema %s failed to compile\n", schemas); in xmlShellRNGValidate()
2375 return(-1); in xmlShellRNGValidate()
2382 ret = xmlRelaxNGValidateDoc(vctxt, sctxt->doc); in xmlShellRNGValidate()
2384 fprintf(stderr, "%s validates\n", sctxt->filename); in xmlShellRNGValidate()
2386 fprintf(stderr, "%s fails to validate\n", sctxt->filename); in xmlShellRNGValidate()
2389 sctxt->filename); in xmlShellRNGValidate()
2418 fprintf(ctxt->output, "NULL\n"); in xmlShellCat()
2421 if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) { in xmlShellCat()
2423 if (node->type == XML_HTML_DOCUMENT_NODE) in xmlShellCat()
2424 htmlDocDump(ctxt->output, (htmlDocPtr) node); in xmlShellCat()
2426 htmlNodeDumpFile(ctxt->output, ctxt->doc, node); in xmlShellCat()
2428 if (node->type == XML_DOCUMENT_NODE) in xmlShellCat()
2429 xmlDocDump(ctxt->output, (xmlDocPtr) node); in xmlShellCat()
2431 xmlElemDump(ctxt->output, ctxt->doc, node); in xmlShellCat()
2434 if (node->type == XML_DOCUMENT_NODE) in xmlShellCat()
2435 xmlDocDump(ctxt->output, (xmlDocPtr) node); in xmlShellCat()
2437 xmlElemDump(ctxt->output, ctxt->doc, node); in xmlShellCat()
2439 fprintf(ctxt->output, "\n"); in xmlShellCat()
2452 * loads a new document specified by the filename
2454 * Returns 0 or -1 if loading failed
2464 if ((ctxt == NULL) || (filename == NULL)) return(-1); in xmlShellLoad()
2465 if (ctxt->doc != NULL) in xmlShellLoad()
2466 html = (ctxt->doc->type == XML_HTML_DOCUMENT_NODE); in xmlShellLoad()
2472 fprintf(ctxt->output, "HTML support not compiled in\n"); in xmlShellLoad()
2479 if (ctxt->loaded == 1) { in xmlShellLoad()
2480 xmlFreeDoc(ctxt->doc); in xmlShellLoad()
2482 ctxt->loaded = 1; in xmlShellLoad()
2484 xmlXPathFreeContext(ctxt->pctxt); in xmlShellLoad()
2486 xmlFree(ctxt->filename); in xmlShellLoad()
2487 ctxt->doc = doc; in xmlShellLoad()
2488 ctxt->node = (xmlNodePtr) doc; in xmlShellLoad()
2490 ctxt->pctxt = xmlXPathNewContext(doc); in xmlShellLoad()
2492 ctxt->filename = (char *) xmlCanonicPath((xmlChar *) filename); in xmlShellLoad()
2494 return (-1); in xmlShellLoad()
2510 * Returns 0 or -1 in case of error
2517 return (-1); in xmlShellWrite()
2519 return (-1); in xmlShellWrite()
2525 return (-1); in xmlShellWrite()
2528 switch (node->type) { in xmlShellWrite()
2530 if (xmlSaveFile((char *) filename, ctxt->doc) < -1) { in xmlShellWrite()
2533 return (-1); in xmlShellWrite()
2538 if (htmlSaveFile((char *) filename, ctxt->doc) < 0) { in xmlShellWrite()
2541 return (-1); in xmlShellWrite()
2544 if (xmlSaveFile((char *) filename, ctxt->doc) < -1) { in xmlShellWrite()
2547 return (-1); in xmlShellWrite()
2558 return (-1); in xmlShellWrite()
2560 xmlElemDump(f, ctxt->doc, node); in xmlShellWrite()
2575 * Write the current document to the filename, or it's original name
2577 * Returns 0 or -1 in case of error
2584 if ((ctxt == NULL) || (ctxt->doc == NULL)) in xmlShellSave()
2585 return (-1); in xmlShellSave()
2587 filename = ctxt->filename; in xmlShellSave()
2589 return (-1); in xmlShellSave()
2594 return (-1); in xmlShellSave()
2597 switch (ctxt->doc->type) { in xmlShellSave()
2599 if (xmlSaveFile((char *) filename, ctxt->doc) < 0) { in xmlShellSave()
2606 if (htmlSaveFile((char *) filename, ctxt->doc) < 0) { in xmlShellSave()
2611 if (xmlSaveFile((char *) filename, ctxt->doc) < 0) { in xmlShellSave()
2619 "To save to subparts of a document use the 'write' command\n"); in xmlShellSave()
2620 return (-1); in xmlShellSave()
2636 * Validate the document, if a DTD path is provided, then the validation
2639 * Returns 0 or -1 in case of error
2647 int res = -1; in xmlShellValidate()
2649 if ((ctxt == NULL) || (ctxt->doc == NULL)) return(-1); in xmlShellValidate()
2655 res = xmlValidateDocument(&vctxt, ctxt->doc); in xmlShellValidate()
2661 res = xmlValidateDtd(&vctxt, ctxt->doc, subset); in xmlShellValidate()
2681 * Returns 0 or -1 in case of error
2692 return (-1); in xmlShellDu()
2695 return (-1); in xmlShellDu()
2698 if ((node->type == XML_DOCUMENT_NODE) || in xmlShellDu()
2699 (node->type == XML_HTML_DOCUMENT_NODE)) { in xmlShellDu()
2700 fprintf(ctxt->output, "/\n"); in xmlShellDu()
2701 } else if (node->type == XML_ELEMENT_NODE) { in xmlShellDu()
2703 fprintf(ctxt->output, " "); in xmlShellDu()
2704 if ((node->ns) && (node->ns->prefix)) in xmlShellDu()
2705 fprintf(ctxt->output, "%s:", node->ns->prefix); in xmlShellDu()
2706 fprintf(ctxt->output, "%s\n", node->name); in xmlShellDu()
2714 if ((node->type == XML_DOCUMENT_NODE) || in xmlShellDu()
2715 (node->type == XML_HTML_DOCUMENT_NODE)) { in xmlShellDu()
2716 node = ((xmlDocPtr) node)->children; in xmlShellDu()
2717 } else if ((node->children != NULL) in xmlShellDu()
2718 && (node->type != XML_ENTITY_REF_NODE)) { in xmlShellDu()
2720 node = node->children; in xmlShellDu()
2722 } else if ((node != tree) && (node->next != NULL)) { in xmlShellDu()
2724 node = node->next; in xmlShellDu()
2726 /* go up to parents->next if needed */ in xmlShellDu()
2728 if (node->parent != NULL) { in xmlShellDu()
2729 node = node->parent; in xmlShellDu()
2730 indent--; in xmlShellDu()
2732 if ((node != tree) && (node->next != NULL)) { in xmlShellDu()
2733 node = node->next; in xmlShellDu()
2736 if (node->parent == NULL) { in xmlShellDu()
2757 * @buffer: the output buffer
2764 * The output is compatible with XPath commands.
2766 * Returns 0 or -1 in case of error
2775 return (-1); in xmlShellPwd()
2779 return (-1); in xmlShellPwd()
2798 * @doc: the initial document
2799 * @filename: the output buffer
2801 * @output: the output FILE*, defaults to stdout if NULL
2804 * This allow to load, validate, view, modify and save a document
2809 FILE * output) in xmlShell() argument
2825 if (output == NULL) in xmlShell()
2826 output = stdout; in xmlShell()
2830 ctxt->loaded = 0; in xmlShell()
2831 ctxt->doc = doc; in xmlShell()
2832 ctxt->input = input; in xmlShell()
2833 ctxt->output = output; in xmlShell()
2834 ctxt->filename = (char *) xmlStrdup((xmlChar *) filename); in xmlShell()
2835 ctxt->node = (xmlNodePtr) ctxt->doc; in xmlShell()
2838 ctxt->pctxt = xmlXPathNewContext(ctxt->doc); in xmlShell()
2839 if (ctxt->pctxt == NULL) { in xmlShell()
2845 if (ctxt->node == (xmlNodePtr) ctxt->doc) in xmlShell()
2847 else if ((ctxt->node != NULL) && (ctxt->node->name) && in xmlShell()
2848 (ctxt->node->ns) && (ctxt->node->ns->prefix)) in xmlShell()
2850 (ctxt->node->ns->prefix), ctxt->node->name); in xmlShell()
2851 else if ((ctxt->node != NULL) && (ctxt->node->name)) in xmlShell()
2852 snprintf(prompt, sizeof(prompt), "%s > ", ctxt->node->name); in xmlShell()
2855 prompt[sizeof(prompt) - 1] = 0; in xmlShell()
2860 cmdline = ctxt->input(prompt); in xmlShell()
2904 fprintf(ctxt->output, "\tbase display XML base of the node\n"); in xmlShell()
2905 fprintf(ctxt->output, "\tsetbase URI change the XML base of the node\n"); in xmlShell()
2906 fprintf(ctxt->output, "\tbye leave shell\n"); in xmlShell()
2907 fprintf(ctxt->output, "\tcat [node] display node or current node\n"); in xmlShell()
2908 fprintf(ctxt->output, "\tcd [path] change directory to path or to root\n"); in xmlShell()
2909 …fprintf(ctxt->output, "\tdir [path] dumps informations about the node (namespace, attributes, co… in xmlShell()
2910 …fprintf(ctxt->output, "\tdu [path] show the structure of the subtree under path or the current … in xmlShell()
2911 fprintf(ctxt->output, "\texit leave shell\n"); in xmlShell()
2912 fprintf(ctxt->output, "\thelp display this help\n"); in xmlShell()
2913 fprintf(ctxt->output, "\tfree display memory usage\n"); in xmlShell()
2914 fprintf(ctxt->output, "\tload [name] load a new document with name\n"); in xmlShell()
2915 fprintf(ctxt->output, "\tls [path] list contents of path or the current directory\n"); in xmlShell()
2916 …fprintf(ctxt->output, "\tset xml_fragment replace the current node content with the fragment parse… in xmlShell()
2918 …fprintf(ctxt->output, "\txpath expr evaluate the XPath expression in that context and print the … in xmlShell()
2919 …fprintf(ctxt->output, "\tsetns nsreg register a namespace to a prefix in the XPath evaluation con… in xmlShell()
2920 …fprintf(ctxt->output, "\t format for nsreg is: prefix=[nsuri] (i.e. prefix= unsets a p… in xmlShell()
2921 fprintf(ctxt->output, "\tsetrootns register all namespace found on the root element\n"); in xmlShell()
2922 fprintf(ctxt->output, "\t the default namespace if any uses 'defaultns' prefix\n"); in xmlShell()
2924 fprintf(ctxt->output, "\tpwd display current working directory\n"); in xmlShell()
2925 …fprintf(ctxt->output, "\twhereis display absolute path of [path] or current working directory… in xmlShell()
2926 fprintf(ctxt->output, "\tquit leave shell\n"); in xmlShell()
2928 fprintf(ctxt->output, "\tsave [name] save this document to name or the original name\n"); in xmlShell()
2929 fprintf(ctxt->output, "\twrite [name] write the current node to the filename\n"); in xmlShell()
2932 fprintf(ctxt->output, "\tvalidate check the document for errors\n"); in xmlShell()
2935 fprintf(ctxt->output, "\trelaxng rng validate the document against the Relax-NG schemas\n"); in xmlShell()
2937 fprintf(ctxt->output, "\tgrep string search for a string in the subtree\n"); in xmlShell()
2956 xmlShellWrite(ctxt, arg, ctxt->node, NULL); in xmlShell()
2959 xmlShellGrep(ctxt, arg, ctxt->node, NULL); in xmlShell()
2962 xmlMemShow(ctxt->output, 0); in xmlShell()
2967 xmlMemShow(ctxt->output, len); in xmlShell()
2972 if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL)) in xmlShell()
2973 fprintf(ctxt->output, "%s\n", dir); in xmlShell()
2976 xmlShellDu(ctxt, NULL, ctxt->node, NULL); in xmlShell()
2978 ctxt->pctxt->node = ctxt->node; in xmlShell()
2980 ctxt->pctxt->node = ctxt->node; in xmlShell()
2981 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt); in xmlShell()
2986 switch (list->type) { in xmlShell()
2994 if (list->nodesetval == NULL) in xmlShell()
2998 indx < list->nodesetval->nodeNr; in xmlShell()
3001 list->nodesetval-> in xmlShell()
3031 "%s is user-defined\n", arg); in xmlShell()
3046 ctxt->pctxt->node = NULL; in xmlShell()
3049 xmlShellBase(ctxt, NULL, ctxt->node, NULL); in xmlShell()
3051 xmlShellSetContent(ctxt, arg, ctxt->node, NULL); in xmlShell()
3063 root = xmlDocGetRootElement(ctxt->doc); in xmlShell()
3070 ctxt->pctxt->node = ctxt->node; in xmlShell()
3071 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt); in xmlShell()
3072 xmlXPathDebugDumpObject(ctxt->output, list, 0); in xmlShell()
3078 xmlShellSetBase(ctxt, arg, ctxt->node, NULL); in xmlShell()
3085 xmlShellDir(ctxt, NULL, ctxt->node, NULL); in xmlShell()
3087 xmlShellList(ctxt, NULL, ctxt->node, NULL); in xmlShell()
3089 ctxt->pctxt->node = ctxt->node; in xmlShell()
3091 ctxt->pctxt->node = ctxt->node; in xmlShell()
3092 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt); in xmlShell()
3097 switch (list->type) { in xmlShell()
3105 if (list->nodesetval == NULL) in xmlShell()
3109 indx < list->nodesetval->nodeNr; in xmlShell()
3113 list->nodesetval-> in xmlShell()
3117 list->nodesetval-> in xmlShell()
3148 "%s is user-defined\n", arg); in xmlShell()
3163 ctxt->pctxt->node = NULL; in xmlShell()
3169 if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL)) in xmlShell()
3170 fprintf(ctxt->output, "%s\n", dir); in xmlShell()
3172 ctxt->pctxt->node = ctxt->node; in xmlShell()
3174 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt); in xmlShell()
3179 switch (list->type) { in xmlShell()
3187 if (list->nodesetval == NULL) in xmlShell()
3191 indx < list->nodesetval->nodeNr; in xmlShell()
3193 if (!xmlShellPwd(ctxt, dir, list->nodesetval-> in xmlShell()
3195 fprintf(ctxt->output, "%s\n", dir); in xmlShell()
3225 "%s is user-defined\n", arg); in xmlShell()
3240 ctxt->pctxt->node = NULL; in xmlShell()
3244 ctxt->node = (xmlNodePtr) ctxt->doc; in xmlShell()
3249 ctxt->pctxt->node = ctxt->node; in xmlShell()
3251 if ((l >= 2) && (arg[l - 1] == '/')) in xmlShell()
3252 arg[l - 1] = 0; in xmlShell()
3253 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt); in xmlShell()
3258 switch (list->type) { in xmlShell()
3264 if (list->nodesetval != NULL) { in xmlShell()
3265 if (list->nodesetval->nodeNr == 1) { in xmlShell()
3266 ctxt->node = list->nodesetval->nodeTab[0]; in xmlShell()
3267 if ((ctxt->node != NULL) && in xmlShell()
3268 (ctxt->node->type == in xmlShell()
3272 ctxt->node = NULL; in xmlShell()
3278 list->nodesetval->nodeNr); in xmlShell()
3310 "%s is user-defined\n", arg); in xmlShell()
3325 ctxt->pctxt->node = NULL; in xmlShell()
3330 xmlShellCat(ctxt, NULL, ctxt->node, NULL); in xmlShell()
3332 ctxt->pctxt->node = ctxt->node; in xmlShell()
3334 ctxt->pctxt->node = ctxt->node; in xmlShell()
3335 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt); in xmlShell()
3340 switch (list->type) { in xmlShell()
3348 if (list->nodesetval == NULL) in xmlShell()
3352 indx < list->nodesetval->nodeNr; in xmlShell()
3355 fprintf(ctxt->output, " -------\n"); in xmlShell()
3357 list->nodesetval-> in xmlShell()
3388 "%s is user-defined\n", arg); in xmlShell()
3403 ctxt->pctxt->node = NULL; in xmlShell()
3414 xmlXPathFreeContext(ctxt->pctxt); in xmlShell()
3416 if (ctxt->loaded) { in xmlShell()
3417 xmlFreeDoc(ctxt->doc); in xmlShell()
3419 if (ctxt->filename != NULL) in xmlShell()
3420 xmlFree(ctxt->filename); in xmlShell()