[xml] xmllint as filter?



I'm looking at using "xmllint" as a filter for a stream of XML-documents that become one large XML document. What I want to do is to inhibit an improperly formed document to enter the stream, which would otherwise improperly form the complete stream.

It seems that "xmllint" could be used for that, if it were not for the <?xml processing directive that is always output.

I've changed the source of xmllint.c to allow for an extra parameter
"--noxmlproc", but now find it difficult to actually get that flag setting passed to "xmlDocContentDumpOutput" in tree.c.

Would it make sense to add parameters to all "intervening" routines that get passed through to "xmlDocContentDumpOutput", or would the introduction of a global variable make more sense? If a global variable would make sense, it would probably have to be one that resets itself after being checked so that you would have to set it each time you would want a document dumped without the <?xml processing directive.

However, I'm too rusty in C to know how to do a global variable: if someone could point me the way towards that, I could create a diff to tree.c as well that would perform the suggested change.


Below a unified diff of the changes I already made to xmllint.c:
----------------------------------------------------------------------------
-- xmllint.original.c   Fri Nov  9 04:35:07 2001
+++ xmllint.c   Fri Nov 23 16:14:04 2001
@@ -82,6 +82,7 @@
 static int recovery = 0;
 static int noent = 0;
 static int noout = 0;
+static int noxmlproc = 0;
 static int nowrap = 0;
 static int valid = 0;
 static int postvalid = 0;
@@ -828,6 +829,7 @@
printf("\t--recover : output what was parsable on broken XML documents\n");
     printf("\t--noent : substitute entity references by their value\n");
     printf("\t--noout : don't output the result tree\n");
+    printf("\t--noxmlproc : don't output the <?xml processing directive\n");
     printf("\t--htmlout : output results as HTML\n");
     printf("\t--nowrap : do not put HTML doc wrapper\n");
printf("\t--valid : validate the document in addition to std well-formed check\n");
@@ -904,6 +906,9 @@
        else if ((!strcmp(argv[i], "-noout")) ||
                 (!strcmp(argv[i], "--noout")))
            noout++;
+       else if ((!strcmp(argv[i], "-noxmlproc")) ||
+                (!strcmp(argv[i], "--noxmlproc")))
+           noxmlproc++;
        else if ((!strcmp(argv[i], "-htmlout")) ||
                 (!strcmp(argv[i], "--htmlout")))
            htmlout++;
----------------------------------------------------------------------------


Hope this made sense...  ;-)


Elizabeth Mattijsen




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]