20#ifdef HAVE_SYS_TIMEB_H
23#ifdef HAVE_SYS_TYPES_H
39#define MAP_FAILED ((void *) -1)
42#ifdef HAVE_LIBREADLINE
43#include <readline/readline.h>
45#include <readline/history.h>
58#ifdef LIBXML_XINCLUDE_ENABLED
61#ifdef LIBXML_CATALOG_ENABLED
66#ifdef LIBXML_SCHEMATRON_ENABLED
69#ifdef LIBXML_SCHEMAS_ENABLED
73#ifdef LIBXML_PATTERN_ENABLED
76#ifdef LIBXML_C14N_ENABLED
79#ifdef LIBXML_OUTPUT_ENABLED
83#ifndef XML_XML_DEFAULT_CATALOG
84#define XML_XML_DEFAULT_CATALOG "file://" SYSCONFDIR "/xml/catalog"
100#ifdef LIBXML_DEBUG_ENABLED
102static int debugent = 0;
106#ifdef LIBXML_TREE_ENABLED
115#ifdef LIBXML_OUTPUT_ENABLED
117static const char *output =
NULL;
119static int oldout = 0;
121#ifdef LIBXML_VALID_ENABLED
123static int postvalid = 0;
124static char * dtdvalid =
NULL;
125static char * dtdvalidfpi =
NULL;
127#ifdef LIBXML_SCHEMAS_ENABLED
128static char * relaxng =
NULL;
129static xmlRelaxNGPtr relaxngschemas =
NULL;
131static xmlSchemaPtr wxschemas =
NULL;
133#ifdef LIBXML_SCHEMATRON_ENABLED
134static char * schematron =
NULL;
135static xmlSchematronPtr wxschematron =
NULL;
139#if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED)
141static int xmlout = 0;
144#if defined(LIBXML_HTML_ENABLED)
145static int nodefdtd = 0;
147#ifdef LIBXML_PUSH_ENABLED
149static int pushsize = 4096;
156#ifdef LIBXML_XINCLUDE_ENABLED
157static int xinclude = 0;
166#ifdef LIBXML_CATALOG_ENABLED
167static int catalogs = 0;
168static int nocatalogs = 0;
170#ifdef LIBXML_C14N_ENABLED
171static int canonical = 0;
172static int canonical_11 = 0;
173static int exc_canonical = 0;
175#ifdef LIBXML_READER_ENABLED
177static int walker = 0;
178#ifdef LIBXML_PATTERN_ENABLED
180static xmlPatternPtr patternc =
NULL;
181static xmlStreamCtxtPtr patstream =
NULL;
186#ifdef LIBXML_SAX1_ENABLED
189#ifdef LIBXML_XPATH_ENABLED
190static const char *xpathquery =
NULL;
203# define PATH_SEPARATOR ';'
205# define PATH_SEPARATOR ':'
247 const char *lastsegment = URL;
248 const char *iter = URL;
253 lastsegment = iter + 1;
275 "Loaded URL=\"%s\" ID=\"%s\"\n",
276 URL ? URL :
"(null)",
288 if (newURL !=
NULL) {
298 "Loaded URL=\"%s\" ID=\"%s\"\n",
313 warning(ctxt,
"failed to load external entity \"%s\"\n", URL);
315 warning(ctxt,
"failed to load external entity \"%s\"\n",
ID);
389#ifndef HAVE_GETTIMEOFDAY
390#ifdef HAVE_SYS_TIMEB_H
391#ifdef HAVE_SYS_TIME_H
395my_gettimeofday(
struct timeval *tvp,
void *tzp)
397 struct timeb timebuffer;
401 tvp->
tv_sec = timebuffer.time;
402 tvp->
tv_usec = timebuffer.millitm * 1000L;
406#define HAVE_GETTIMEOFDAY 1
407#define gettimeofday my_gettimeofday
414#if defined(HAVE_GETTIMEOFDAY)
440 msec += (
end.tv_usec -
begin.tv_usec) / 1000;
454#ifndef CLOCKS_PER_SEC
455#define CLOCKS_PER_SEC 100
518 if (
input->filename) {
549 while ((
n++ < 80) && (
cur >
base) && (*
cur !=
'\n') && (*
cur !=
'\r'))
551 if ((*
cur ==
'\n') || (*
cur ==
'\r'))
cur++;
554 while ((*
cur != 0) && (*
cur !=
'\n') && (*
cur !=
'\r') && (
n < 79)) {
557 (
unsigned char) *
cur++);
563 while ((*
cur ==
'\n') || (*
cur ==
'\r'))
566 while ((
cur !=
base) && (
n++ < 80)) {
662xmlHTMLValidityError(
void *
ctx,
const char *
msg, ...)
699xmlHTMLValidityWarning(
void *
ctx,
const char *
msg, ...)
730#ifdef LIBXML_DEBUG_ENABLED
731#ifdef LIBXML_XPATH_ENABLED
742xmlShellReadline(
char *prompt) {
743#ifdef HAVE_LIBREADLINE
750 if (line_read && *line_read)
751 add_history (line_read);
908 if (ExternalID ==
NULL)
912 if (SystemID ==
NULL)
932 if (ExternalID ==
NULL)
936 if (SystemID ==
NULL)
966 if (publicId !=
NULL)
970 if (systemId !=
NULL)
1033 if (publicId ==
NULL)
1035 if (systemId ==
NULL)
1062 if (defaultValue ==
NULL)
1063 fprintf(
stdout,
"SAX.attributeDecl(%s, %s, %d, %d, NULL, ...)\n",
1066 fprintf(
stdout,
"SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",
1108 (
char *)
name, (
char *) publicId, (
char *) systemId);
1128 if (publicId ==
NULL)
1130 if (systemId ==
NULL)
1132 if (notationName ==
NULL)
1133 notationName = nullstr;
1138 (
char *)
name, (
char *) publicId, (
char *) systemId,
1139 (
char *) notationName);
1249 for (
i = 0;(
i<
len) && (
i < 30);
i++)
1291 for (
i = 0;(
i<
len) && (
i < 30);
i++)
1487 fprintf(
stdout,
"SAX.startElementNs(%s", (
char *) localname);
1498 if (namespaces !=
NULL) {
1499 for (
i = 0;
i < nb_namespaces * 2;
i++) {
1501 if (namespaces[
i] !=
NULL)
1508 if (attributes !=
NULL) {
1509 for (
i = 0;
i < nb_attributes * 5;
i += 5) {
1510 if (attributes[
i + 1] !=
NULL)
1515 (
int)(attributes[
i + 4] - attributes[
i + 3]));
1588 const char *user_data =
"user_data";
1598#ifdef LIBXML_SAX1_ENABLED
1614#ifdef LIBXML_SCHEMAS_ENABLED
1615 if (wxschemas !=
NULL) {
1617 xmlSchemaValidCtxtPtr vctxt;
1619 vctxt = xmlSchemaNewValidCtxt(wxschemas);
1620 if (vctxt ==
NULL) {
1626 xmlSchemaValidateSetFilename(vctxt,
filename);
1635 }
else if (
ret > 0) {
1639 fprintf(
stderr,
"%s validation generated an internal error\n",
1644 xmlSchemaFreeValidCtxt(vctxt);
1657 old_sax = ctxt->
sax;
1659 ctxt->
userData = (
void *) user_data;
1661 if (inputStream ==
NULL) {
1679 ctxt->
sax = old_sax;
1689#ifdef LIBXML_READER_ENABLED
1690static void processNode(xmlTextReaderPtr
reader) {
1706 xmlTextReaderDepth(
reader),
1710 xmlTextReaderHasValue(
reader));
1717#ifdef LIBXML_PATTERN_ENABLED
1722 if (
type == XML_READER_TYPE_ELEMENT) {
1724 match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(
reader));
1727#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
1728 path = xmlGetNodePath(xmlTextReaderCurrentNode(
reader));
1731 printf(
"Node %s matches pattern %s\n",
1736 if (patstream !=
NULL) {
1739 if (
type == XML_READER_TYPE_ELEMENT) {
1740 ret = xmlStreamPush(patstream,
1741 xmlTextReaderConstLocalName(
reader),
1742 xmlTextReaderConstNamespaceUri(
reader));
1745 xmlFreeStreamCtxt(patstream);
1748#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
1750 path = xmlGetNodePath(
1751 xmlTextReaderCurrentNode(
reader));
1755 "xmlPatternMatch and xmlStreamPush disagree\n");
1765 if ((
type == XML_READER_TYPE_END_ELEMENT) ||
1766 ((
type == XML_READER_TYPE_ELEMENT) && (
empty))) {
1767 ret = xmlStreamPop(patstream);
1770 xmlFreeStreamCtxt(patstream);
1781static void streamFile(
char *
filename) {
1808#ifdef LIBXML_PATTERN_ENABLED
1811 if (patternc ==
NULL) {
1813 "Pattern %s failed to compile\n",
pattern);
1818 if (patternc !=
NULL) {
1819 patstream = xmlPatternGetStreamCtxt(patternc);
1820 if (patstream !=
NULL) {
1824 xmlFreeStreamCtxt(patstream);
1833#ifdef LIBXML_VALID_ENABLED
1835 xmlTextReaderSetParserProp(
reader, XML_PARSER_VALIDATE, 1);
1839 xmlTextReaderSetParserProp(
reader, XML_PARSER_LOADDTD, 1);
1840#ifdef LIBXML_SCHEMAS_ENABLED
1841 if (relaxng !=
NULL) {
1845 ret = xmlTextReaderRelaxNGValidate(
reader, relaxng);
1848 "Relax-NG schema %s failed to compile\n", relaxng);
1853 endTimer(
"Compiling the schemas");
1863 "XSD schema %s failed to compile\n",
schema);
1868 endTimer(
"Compiling the schemas");
1890#ifdef LIBXML_SCHEMAS_ENABLED
1891 if (relaxng !=
NULL)
1892 endTimer(
"Parsing and validating");
1895#ifdef LIBXML_VALID_ENABLED
1897 endTimer(
"Parsing and validating");
1900 endTimer(
"Parsing");
1903#ifdef LIBXML_VALID_ENABLED
1905 if (xmlTextReaderIsValid(
reader) != 1) {
1907 "Document %s does not validate\n",
filename);
1912#ifdef LIBXML_SCHEMAS_ENABLED
1914 if (xmlTextReaderIsValid(
reader) != 1) {
1927 xmlFreeTextReader(
reader);
1936#ifdef LIBXML_PATTERN_ENABLED
1937 if (patstream !=
NULL) {
1938 xmlFreeStreamCtxt(patstream);
1945 munmap((
char *)
base,
info.st_size);
1955#ifdef LIBXML_PATTERN_ENABLED
1957 const xmlChar *namespaces[22];
1964 "Document does not have a root element");
1969 namespaces[
i++] =
ns->href;
1972 namespaces[
i++] =
NULL;
1973 namespaces[
i] =
NULL;
1978 if (patternc ==
NULL) {
1980 "Pattern %s failed to compile\n",
pattern);
1985 if (patternc !=
NULL) {
1986 patstream = xmlPatternGetStreamCtxt(patternc);
1987 if (patstream !=
NULL) {
1991 xmlFreeStreamCtxt(patstream);
1997 reader = xmlReaderWalker(doc);
2013 endTimer(
"walking through the doc");
2015 xmlFreeTextReader(
reader);
2021 fprintf(
stderr,
"Failed to crate a reader from the document\n");
2024#ifdef LIBXML_PATTERN_ENABLED
2025 if (patstream !=
NULL) {
2026 xmlFreeStreamCtxt(patstream);
2033#ifdef LIBXML_XPATH_ENABLED
2040static void doXPathDump(xmlXPathObjectPtr
cur) {
2042 case XPATH_NODESET: {
2045#ifdef LIBXML_OUTPUT_ENABLED
2048 if ((
cur->nodesetval ==
NULL) || (
cur->nodesetval->nodeNr <= 0)) {
2059 for (
i = 0;
i <
cur->nodesetval->nodeNr;
i++) {
2060 node =
cur->nodesetval->nodeTab[
i];
2062 xmlOutputBufferWrite(
buf, 1,
"\n");
2064 xmlOutputBufferClose(
buf);
2066 printf(
"xpath returned %d nodes\n",
cur->nodesetval->nodeNr);
2075 switch (xmlXPathIsInf(
cur->floatval)) {
2083 if (xmlXPathIsNaN(
cur->floatval)) {
2091 printf(
"%s\n", (
const char *)
cur->stringval);
2093 case XPATH_UNDEFINED:
2105 xmlXPathContextPtr ctxt;
2106 xmlXPathObjectPtr
res;
2108 ctxt = xmlXPathNewContext(doc);
2116 xmlXPathFreeContext(ctxt);
2124 xmlXPathFreeObject(
res);
2135#ifdef LIBXML_TREE_ENABLED
2143#ifdef LIBXML_TREE_ENABLED
2151 xmlDocSetRootElement(doc,
n);
2155#ifdef LIBXML_HTML_ENABLED
2156#ifdef LIBXML_PUSH_ENABLED
2157 else if ((html) && (
push)) {
2168 htmlParserCtxtPtr ctxt;
2172 ctxt = htmlCreatePushParserCtxt(
NULL,
NULL,
2180 htmlCtxtUseOptions(ctxt,
options);
2181 while ((
res =
fread(chars, 1, pushsize,
f)) > 0) {
2182 htmlParseChunk(ctxt, chars,
res, 0);
2184 htmlParseChunk(ctxt, chars, 0, 1);
2186 htmlFreeParserCtxt(ctxt);
2194 else if ((html) && (
memory)) {
2213 munmap((
char *)
base,
info.st_size);
2222#ifdef LIBXML_PUSH_ENABLED
2244 ctxt = xmlCreatePushParserCtxt(
NULL,
NULL,
2254 xmlParseChunk(ctxt, chars,
res, 0);
2256 xmlParseChunk(ctxt, chars, 0, 1);
2290 if (rectxt ==
NULL) {
2300 ctxt->
sax->error = xmlHTMLError;
2301 ctxt->
sax->warning = xmlHTMLWarning;
2302 ctxt->
vctxt.error = xmlHTMLValidityError;
2303 ctxt->
vctxt.warning = xmlHTMLValidityWarning;
2333 munmap((
char *)
base,
info.st_size);
2336#ifdef LIBXML_VALID_ENABLED
2340 if (rectxt ==
NULL) {
2352 if (ctxt->
valid == 0)
2361#ifdef LIBXML_SAX1_ENABLED
2380 endTimer(
"Parsing");
2397#ifdef LIBXML_XINCLUDE_ENABLED
2402 if (xmlXIncludeProcessFlags(doc,
options) < 0)
2405 endTimer(
"Xinclude processing");
2410#ifdef LIBXML_XPATH_ENABLED
2411 if (xpathquery !=
NULL) {
2412 doXPathQuery(doc, xpathquery);
2416#ifdef LIBXML_DEBUG_ENABLED
2417#ifdef LIBXML_XPATH_ENABLED
2422 xmlXPathOrderDocElems(doc);
2428#ifdef LIBXML_TREE_ENABLED
2437 doc = xmlCopyDoc(doc, 1);
2439 endTimer(
"Copying");
2446 endTimer(
"Freeing original");
2451#ifdef LIBXML_VALID_ENABLED
2452 if ((
insert) && (!html)) {
2461 nb = xmlValidGetValidElements(
node->last,
NULL,
list, 256);
2464 }
else if (nb == 0) {
2467 fprintf(
stderr,
"%d element types can be inserted under root:\n",
2469 for (
i = 0;
i < nb;
i++) {
2477#ifdef LIBXML_READER_ENABLED
2482#ifdef LIBXML_OUTPUT_ENABLED
2489#ifdef LIBXML_DEBUG_ENABLED
2495#ifdef LIBXML_HTML_ENABLED
2496 if ((html) && (!xmlout)) {
2498 htmlSaveFile(output ? output :
"-", doc);
2502 htmlSaveFileFormat(output ? output :
"-", doc,
encoding, 1);
2505 htmlSaveFileFormat(output ? output :
"-", doc,
encoding, 0);
2509 htmlSaveFileFormat(output ? output :
"-", doc,
NULL, 1);
2519 if (htmlDocDump(
out, doc) < 0)
2534#ifdef LIBXML_C14N_ENABLED
2549 }
else if (canonical_11) {
2564 if (exc_canonical) {
2593 xmlDocDumpFormatMemory(doc, &
result, &
len, 1);
2610 xmlSaveFile(output ? output :
"-", doc);
2611 }
else if (oldout) {
2614 ret = xmlSaveFormatFileEnc(output ? output :
"-", doc,
2618 ret = xmlSaveFileEnc(output ? output :
"-", doc,
2623 output ? output :
"-");
2626 }
else if (
format == 1) {
2627 ret = xmlSaveFormatFile(output ? output :
"-", doc, 1);
2630 output ? output :
"-");
2641 if (xmlDocDump(
out, doc) < 0)
2652 xmlSaveCtxtPtr ctxt;
2656 saveOpts |= XML_SAVE_FORMAT;
2658 saveOpts |= XML_SAVE_WSNONSIG;
2660#if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED)
2662 saveOpts |= XML_SAVE_AS_XML;
2666 ctxt = xmlSaveToFd(1,
encoding, saveOpts);
2668 ctxt = xmlSaveToFilename(output,
encoding, saveOpts);
2671 if (xmlSaveDoc(ctxt, doc) < 0) {
2673 output ? output :
"-");
2684#ifdef LIBXML_DEBUG_ENABLED
2693 xmlDebugDumpDocument(
out, doc);
2706#ifdef LIBXML_VALID_ENABLED
2710 if ((dtdvalid !=
NULL) || (dtdvalidfpi !=
NULL)) {
2716 if (dtdvalid !=
NULL)
2717 dtd = xmlParseDTD(
NULL, (
const xmlChar *)dtdvalid);
2719 dtd = xmlParseDTD((
const xmlChar *)dtdvalidfpi,
NULL);
2721 endTimer(
"Parsing DTD");
2724 if (dtdvalid !=
NULL)
2726 "Could not parse DTD %s\n", dtdvalid);
2729 "Could not parse DTD %s\n", dtdvalidfpi);
2734 if ((cvp = xmlNewValidCtxt()) ==
NULL) {
2736 "Couldn't allocate validation context\n");
2741 cvp->userData =
NULL;
2748 if (!xmlValidateDtd(cvp, doc, dtd)) {
2749 if (dtdvalid !=
NULL)
2751 "Document %s does not validate against %s\n",
2755 "Document %s does not validate against %s\n",
2760 endTimer(
"Validating against DTD");
2762 xmlFreeValidCtxt(cvp);
2765 }
else if (postvalid) {
2768 if ((cvp = xmlNewValidCtxt()) ==
NULL) {
2770 "Couldn't allocate validation context\n");
2779 cvp->userData =
NULL;
2782 if (!xmlValidateDocument(cvp, doc)) {
2784 "Document %s does not validate\n",
filename);
2788 endTimer(
"Validating");
2790 xmlFreeValidCtxt(cvp);
2793#ifdef LIBXML_SCHEMATRON_ENABLED
2794 if (wxschematron !=
NULL) {
2795 xmlSchematronValidCtxtPtr ctxt;
2804 flag = XML_SCHEMATRON_OUT_XML;
2806 flag = XML_SCHEMATRON_OUT_TEXT;
2808 flag |= XML_SCHEMATRON_OUT_QUIET;
2809 ctxt = xmlSchematronNewValidCtxt(wxschematron,
flag);
2819 ret = xmlSchematronValidateDoc(ctxt, doc);
2824 }
else if (
ret > 0) {
2828 fprintf(
stderr,
"%s validation generated an internal error\n",
2832 xmlSchematronFreeValidCtxt(ctxt);
2834 endTimer(
"Validating");
2838#ifdef LIBXML_SCHEMAS_ENABLED
2839 if (relaxngschemas !=
NULL) {
2840 xmlRelaxNGValidCtxtPtr ctxt;
2847 ctxt = xmlRelaxNGNewValidCtxt(relaxngschemas);
2854 ret = xmlRelaxNGValidateDoc(ctxt, doc);
2859 }
else if (
ret > 0) {
2863 fprintf(
stderr,
"%s validation generated an internal error\n",
2867 xmlRelaxNGFreeValidCtxt(ctxt);
2869 endTimer(
"Validating");
2871 }
else if (wxschemas !=
NULL) {
2872 xmlSchemaValidCtxtPtr ctxt;
2879 ctxt = xmlSchemaNewValidCtxt(wxschemas);
2886 ret = xmlSchemaValidateDoc(ctxt, doc);
2891 }
else if (
ret > 0) {
2895 fprintf(
stderr,
"%s validation generated an internal error\n",
2899 xmlSchemaFreeValidCtxt(ctxt);
2901 endTimer(
"Validating");
2906#ifdef LIBXML_DEBUG_ENABLED
2907#if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED)
2908 if ((debugent) && (!html))
2909 xmlDebugDumpEntities(
stderr, doc);
2921 endTimer(
"Freeing");
2971 fprintf(
f,
"Usage : %s [options] XMLfiles ...\n",
name);
2972#ifdef LIBXML_OUTPUT_ENABLED
2973 fprintf(
f,
"\tParse the XML files and output the result of the parsing\n");
2975 fprintf(
f,
"\tParse the XML files\n");
2977 fprintf(
f,
"\t--version : display the version of the XML library used\n");
2978#ifdef LIBXML_DEBUG_ENABLED
2979 fprintf(
f,
"\t--debug : dump a debug tree of the in-memory document\n");
2980 fprintf(
f,
"\t--shell : run a navigating shell\n");
2981 fprintf(
f,
"\t--debugent : debug the entities defined in the document\n");
2983#ifdef LIBXML_READER_ENABLED
2984 fprintf(
f,
"\t--debug : dump the nodes content when using --stream\n");
2987#ifdef LIBXML_TREE_ENABLED
2988 fprintf(
f,
"\t--copy : used to test the internal copy implementation\n");
2990 fprintf(
f,
"\t--recover : output what was parsable on broken XML documents\n");
2991 fprintf(
f,
"\t--huge : remove any internal arbitrary parser limits\n");
2992 fprintf(
f,
"\t--noent : substitute entity references by their value\n");
2993 fprintf(
f,
"\t--noenc : ignore any encoding specified inside the document\n");
2994 fprintf(
f,
"\t--noout : don't output the result tree\n");
2995 fprintf(
f,
"\t--path 'paths': provide a set of paths for resources\n");
2996 fprintf(
f,
"\t--load-trace : print trace of all external entities loaded\n");
2997 fprintf(
f,
"\t--nonet : refuse to fetch DTDs or entities over network\n");
2998 fprintf(
f,
"\t--nocompact : do not generate compact text nodes\n");
2999 fprintf(
f,
"\t--htmlout : output results as HTML\n");
3000 fprintf(
f,
"\t--nowrap : do not put HTML doc wrapper\n");
3001#ifdef LIBXML_VALID_ENABLED
3002 fprintf(
f,
"\t--valid : validate the document in addition to std well-formed check\n");
3003 fprintf(
f,
"\t--postvalid : do a posteriori validation, i.e after parsing\n");
3004 fprintf(
f,
"\t--dtdvalid URL : do a posteriori validation against a given DTD\n");
3005 fprintf(
f,
"\t--dtdvalidfpi FPI : same but name the DTD with a Public Identifier\n");
3007 fprintf(
f,
"\t--quiet : be quiet when succeeded\n");
3008 fprintf(
f,
"\t--timing : print some timings\n");
3009 fprintf(
f,
"\t--output file or -o file: save to a given file\n");
3010 fprintf(
f,
"\t--repeat : repeat 100 times, for timing or profiling\n");
3011 fprintf(
f,
"\t--insert : ad-hoc test for valid insertions\n");
3012#ifdef LIBXML_OUTPUT_ENABLED
3013#ifdef LIBXML_ZLIB_ENABLED
3014 fprintf(
f,
"\t--compress : turn on gzip compression of output\n");
3017#ifdef LIBXML_HTML_ENABLED
3018 fprintf(
f,
"\t--html : use the HTML parser\n");
3019 fprintf(
f,
"\t--xmlout : force to use the XML serializer when using --html\n");
3020 fprintf(
f,
"\t--nodefdtd : do not default HTML doctype\n");
3022#ifdef LIBXML_PUSH_ENABLED
3023 fprintf(
f,
"\t--push : use the push mode of the parser\n");
3024 fprintf(
f,
"\t--pushsmall : use the push mode of the parser using tiny increments\n");
3027 fprintf(
f,
"\t--memory : parse from memory\n");
3029 fprintf(
f,
"\t--maxmem nbbytes : limits memory allocation to nbbytes bytes\n");
3030 fprintf(
f,
"\t--nowarning : do not emit warnings from parser/validator\n");
3031 fprintf(
f,
"\t--noblanks : drop (ignorable?) blanks spaces\n");
3032 fprintf(
f,
"\t--nocdata : replace cdata section with text nodes\n");
3033#ifdef LIBXML_OUTPUT_ENABLED
3034 fprintf(
f,
"\t--format : reformat/reindent the output\n");
3035 fprintf(
f,
"\t--encode encoding : output in the given encoding\n");
3036 fprintf(
f,
"\t--dropdtd : remove the DOCTYPE of the input docs\n");
3037 fprintf(
f,
"\t--pretty STYLE : pretty-print in a particular style\n");
3038 fprintf(
f,
"\t 0 Do not pretty print\n");
3039 fprintf(
f,
"\t 1 Format the XML content, as --format\n");
3040 fprintf(
f,
"\t 2 Add whitespace inside tags, preserving content\n");
3042 fprintf(
f,
"\t--c14n : save in W3C canonical format v1.0 (with comments)\n");
3043 fprintf(
f,
"\t--c14n11 : save in W3C canonical format v1.1 (with comments)\n");
3044 fprintf(
f,
"\t--exc-c14n : save in W3C exclusive canonical format (with comments)\n");
3045#ifdef LIBXML_C14N_ENABLED
3047 fprintf(
f,
"\t--nsclean : remove redundant namespace declarations\n");
3048 fprintf(
f,
"\t--testIO : test user I/O support\n");
3049#ifdef LIBXML_CATALOG_ENABLED
3050 fprintf(
f,
"\t--catalogs : use SGML catalogs from $SGML_CATALOG_FILES\n");
3051 fprintf(
f,
"\t otherwise XML Catalogs starting from \n");
3053 fprintf(
f,
"\t--nocatalogs: deactivate all catalogs\n");
3055 fprintf(
f,
"\t--auto : generate a small doc on the fly\n");
3056#ifdef LIBXML_XINCLUDE_ENABLED
3057 fprintf(
f,
"\t--xinclude : do XInclude processing\n");
3058 fprintf(
f,
"\t--noxincludenode : same but do not generate XInclude nodes\n");
3059 fprintf(
f,
"\t--nofixup-base-uris : do not fixup xml:base uris\n");
3061 fprintf(
f,
"\t--loaddtd : fetch external DTD\n");
3062 fprintf(
f,
"\t--dtdattr : loaddtd + populate the tree with inherited attributes \n");
3063#ifdef LIBXML_READER_ENABLED
3064 fprintf(
f,
"\t--stream : use the streaming interface to process very large files\n");
3065 fprintf(
f,
"\t--walker : create a reader and walk though the resulting doc\n");
3066#ifdef LIBXML_PATTERN_ENABLED
3067 fprintf(
f,
"\t--pattern pattern_value : test the pattern support\n");
3070 fprintf(
f,
"\t--chkregister : verify the node registration code\n");
3071#ifdef LIBXML_SCHEMAS_ENABLED
3072 fprintf(
f,
"\t--relaxng schema : do RelaxNG validation against the schema\n");
3073 fprintf(
f,
"\t--schema schema : do validation against the WXS schema\n");
3075#ifdef LIBXML_SCHEMATRON_ENABLED
3076 fprintf(
f,
"\t--schematron schema : do validation against a schematron\n");
3078#ifdef LIBXML_SAX1_ENABLED
3079 fprintf(
f,
"\t--sax1: use the old SAX1 interfaces for processing\n");
3081 fprintf(
f,
"\t--sax: do not build a tree but work just at the SAX level\n");
3082 fprintf(
f,
"\t--oldxml10: use XML-1.0 parsing rules before the 5th edition\n");
3083#ifdef LIBXML_XPATH_ENABLED
3084 fprintf(
f,
"\t--xpath expr: evaluate the XPath expression, imply --noout\n");
3087 fprintf(
f,
"\nLibxml project home page: https://gitlab.gnome.org/GNOME/libxml2\n");
3094 fprintf(
stderr,
"Out of memory in xmllint:registerNode()\n");
3097 *(
long*)
node->_private = (
long) 0x81726354;
3104 assert(*(
long*)
node->_private == (
long) 0x81726354);
3123 if (
argv[
i][0] !=
'-')
3146#ifdef LIBXML_DEBUG_ENABLED
3153#ifdef LIBXML_TREE_ENABLED
3189#ifdef LIBXML_OUTPUT_ENABLED
3203#ifdef LIBXML_HTML_ENABLED
3214 options |= HTML_PARSE_NODEFDTD;
3227#ifdef LIBXML_VALID_ENABLED
3246 dtdvalidfpi =
argv[
i];
3273#ifdef LIBXML_PUSH_ENABLED
3291#ifdef LIBXML_XINCLUDE_ENABLED
3303 else if ((!
strcmp(
argv[
i],
"-nofixup-base-uris")) ||
3310#ifdef LIBXML_OUTPUT_ENABLED
3311#ifdef LIBXML_ZLIB_ENABLED
3331#ifdef LIBXML_DEBUG_ENABLED
3338#ifdef LIBXML_C14N_ENABLED
3355#ifdef LIBXML_CATALOG_ENABLED
3386#ifdef LIBXML_OUTPUT_ENABLED
3394#ifdef LIBXML_OUTPUT_ENABLED
3404#ifdef LIBXML_READER_ENABLED
3413#ifdef LIBXML_PATTERN_ENABLED
3421#ifdef LIBXML_SAX1_ENABLED
3435#ifdef LIBXML_SCHEMAS_ENABLED
3448#ifdef LIBXML_SCHEMATRON_ENABLED
3452 schematron =
argv[
i];
3461 options &= ~XML_PARSE_COMPACT;
3469#ifdef LIBXML_XPATH_ENABLED
3474 xpathquery =
argv[
i];
3487#ifdef LIBXML_CATALOG_ENABLED
3488 if (nocatalogs == 0) {
3492 catal =
getenv(
"SGML_CATALOG_FILES");
3493 if (catal !=
NULL) {
3494 xmlLoadCatalogs(catal);
3502#ifdef LIBXML_SAX1_ENABLED
3504 xmlSAXDefaultVersion(1);
3506 xmlSAXDefaultVersion(2);
3529#ifdef LIBXML_VALID_ENABLED
3534 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n");
3536 "\t\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n");
3538 "<html><head><title>%s output</title></head>\n",
3541 "<body bgcolor=\"#ffffff\"><h1 align=\"center\">%s output</h1>\n",
3545#ifdef LIBXML_SCHEMATRON_ENABLED
3546 if ((schematron !=
NULL) && (
sax == 0)
3551 xmlSchematronParserCtxtPtr ctxt;
3559 ctxt = xmlSchematronNewParserCtxt(schematron);
3568 wxschematron = xmlSchematronParse(ctxt);
3569 if (wxschematron ==
NULL) {
3571 "Schematron schema %s failed to compile\n", schematron);
3575 xmlSchematronFreeParserCtxt(ctxt);
3577 endTimer(
"Compiling the schemas");
3581#ifdef LIBXML_SCHEMAS_ENABLED
3582 if ((relaxng !=
NULL) && (
sax == 0)
3587 xmlRelaxNGParserCtxtPtr ctxt;
3595 ctxt = xmlRelaxNGNewParserCtxt(relaxng);
3602 relaxngschemas = xmlRelaxNGParse(ctxt);
3603 if (relaxngschemas ==
NULL) {
3605 "Relax-NG schema %s failed to compile\n", relaxng);
3609 xmlRelaxNGFreeParserCtxt(ctxt);
3611 endTimer(
"Compiling the schemas");
3618 xmlSchemaParserCtxtPtr ctxt;
3623 ctxt = xmlSchemaNewParserCtxt(
schema);
3629 wxschemas = xmlSchemaParse(ctxt);
3630 if (wxschemas ==
NULL) {
3632 "WXS schema %s failed to compile\n",
schema);
3636 xmlSchemaFreeParserCtxt(ctxt);
3638 endTimer(
"Compiling the schemas");
3642#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED)
3645 if (patternc ==
NULL) {
3647 "Pattern %s failed to compile\n",
pattern);
3664#ifdef LIBXML_VALID_ENABLED
3706#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED)
3713#ifdef LIBXML_XPATH_ENABLED
3727 for (acount = 0;acount <
repeat;acount++) {
3728#ifdef LIBXML_READER_ENABLED
3730 streamFile(
argv[
i]);
3740#ifdef LIBXML_READER_ENABLED
3749#ifdef LIBXML_READER_ENABLED
3751 streamFile(
argv[
i]);
3767 endTimer(
"%d iterations",
repeat);
3780#ifdef LIBXML_SCHEMATRON_ENABLED
3781 if (wxschematron !=
NULL)
3782 xmlSchematronFree(wxschematron);
3784#ifdef LIBXML_SCHEMAS_ENABLED
3785 if (relaxngschemas !=
NULL)
3786 xmlRelaxNGFree(relaxngschemas);
3787 if (wxschemas !=
NULL)
3788 xmlSchemaFree(wxschemas);
3790#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED)
3791 if (patternc !=
NULL)
3792 xmlFreePattern(patternc);
int strcmp(const char *String1, const char *String2)
ACPI_SIZE strlen(const char *String)
#define gettimeofday(tv, tz)
static logline * readline(FILE *inf, adns_state adns, int opts)
void shell(int argc, const char *argv[])
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
_In_ uint16_t _Out_ ULONG * atts
static const WCHAR indent[]
static const WCHAR empty[]
static const WCHAR version[]
UINT(* handler)(MSIPACKAGE *)
XMLPUBFUN int XMLCALL xmlAddEncodingAlias(const char *name, const char *alias)
XMLPUBFUN xmlChar *XMLCALL xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input)
GLuint GLuint GLsizei GLenum type
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLenum GLenum input
GLsizeiptr const GLvoid GLenum usage
GLsizei const GLuint * paths
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 flag
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_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _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,...)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
#define memcpy(s1, s2, n)
static char memory[1024 *256]
XMLPUBFUN int XMLCALL inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
static unsigned __int64 next
static void push(calc_node_t *op)
_Check_return_ _CRTIMP clock_t __cdecl clock(void)
XMLPUBVAR int xmlParserDebugEntities
XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
XMLPUBVAR int xmlGetWarningsDefaultValue
XMLPUBVAR int xmlLoadExtDtdDefaultValue
XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
XMLPUBVAR const char * xmlParserVersion
XMLPUBVAR int xmlDoValidityCheckingDefaultValue
XMLPUBVAR const char * xmlTreeIndentString
XMLPUBVAR xmlFreeFunc xmlFree
XMLPUBVAR void * xmlGenericErrorContext
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
XMLPUBFUN xmlDocPtr XMLCALL xmlReadMemory(const char *buffer, int size, const char *URL, const char *encoding, int options)
XMLPUBFUN int XMLCALL xmlKeepBlanksDefault(int val)
XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options)
XMLPUBFUN int XMLCALL xmlHasFeature(xmlFeature feature)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
XMLPUBFUN xmlDocPtr XMLCALL xmlReadFile(const char *URL, const char *encoding, int options)
XMLPUBFUN void XMLCALL xmlCleanupParser(void)
void(XMLCDECL * warningSAXFunc)(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
#define XML_COMPLETE_ATTRS
void(XMLCDECL *) typedef void(XMLCDECL * errorSAXFunc)(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size, const char *URL, const char *encoding, int options)
XMLPUBFUN xmlDocPtr XMLCALL xmlReadFd(int fd, const char *URL, const char *encoding, int options)
XMLPUBFUN xmlExternalEntityLoader XMLCALL xmlGetExternalEntityLoader(void)
XMLPUBFUN int XMLCALL xmlPedanticParserDefault(int val)
XMLPUBFUN int XMLCALL xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
XMLPUBFUN xmlDocPtr XMLCALL xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
XMLPUBFUN int XMLCALL xmlLineNumbersDefault(int val)
XMLPUBFUN void XMLCALL xmlSetExternalEntityLoader(xmlExternalEntityLoader f)
XMLPUBFUN int XMLCALL xmlSubstituteEntitiesDefault(int val)
XMLPUBFUN int XMLCALL xmlParseDocument(xmlParserCtxtPtr ctxt)
XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadFile(xmlParserCtxtPtr ctxt, const char *filename, const char *encoding, int options)
xmlParserInputPtr(* xmlExternalEntityLoader)(const char *URL, const char *ID, xmlParserCtxtPtr context)
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)
XMLPUBFUN xmlNodePtr XMLCALL xmlDocGetRootElement(const xmlDoc *doc)
XMLPUBFUN void XMLCALL xmlSetCompressMode(int mode)
XMLPUBFUN void XMLCALL xmlFreeDtd(xmlDtdPtr cur)
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content)
xmlOutputBuffer * xmlOutputBufferPtr
XMLPUBFUN xmlDocPtr XMLCALL xmlNewDoc(const xmlChar *version)
XMLPUBFUN xmlDtdPtr XMLCALL xmlGetIntSubset(const xmlDoc *doc)
XMLPUBFUN void XMLCALL xmlUnlinkNode(xmlNodePtr cur)
xmlParserCtxt * xmlParserCtxtPtr
XMLPUBFUN void XMLCALL xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content)
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
struct _xmlDtd * intSubset
struct _xmlNode * children
struct _xmlSAXHandler * sax
xmlParserInputPtr * inputTab
__CRT_INLINE void __cdecl ftime(struct timeb *_Tmb)
XMLPUBFUN void XMLCALL xmlFreeEnumeration(xmlEnumerationPtr cur)
xmlValidCtxt * xmlValidCtxtPtr
void int int ULONGLONG int va_list * ap
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNoNetExternalEntityLoader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc)
static void notationDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
#define XML_XML_DEFAULT_CATALOG
static char * myStrdupFunc(const char *str)
static xmlEntityPtr getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
static xmlSAXHandler debugSAX2HandlerStruct
xmlSAXHandlerPtr debugSAXHandler
static void externalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
static void startTimer(void)
static void xmlHTMLPrintFileContext(xmlParserInputPtr input)
static void endElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
static void deregisterNode(xmlNodePtr node)
static void registerNode(xmlNodePtr node)
static xmlParserInputPtr xmllintExternalEntityLoader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
static void parsePath(const xmlChar *path)
static void referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
static void unparsedEntityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName)
static xmlExternalEntityLoader defaultEntityLoader
static xmllintReturnCode progresult
static void endDocumentDebug(void *ctx ATTRIBUTE_UNUSED)