From: handa Date: Fri, 12 Sep 2008 11:04:50 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f63bf60fe27c4f82abd0329d964d0ee8ea5b262e;p=m17n%2Fm17n-test.git *** empty log message *** --- diff --git a/mim-xml.c b/mim-xml.c new file mode 100644 index 0000000..a2587b1 --- /dev/null +++ b/mim-xml.c @@ -0,0 +1,62 @@ +#include +#include +#include +#include +#include + +void +error_exit (char *fmt, char *arg) +{ + fprintf (stderr, fmt, arg); + exit (1); +} + +int +main (int argc, char **argv) +{ +#if 0 + XPathContextPtr context; + xmlXPathObjectPtr result; + xmlChar *xpath = (xmlChar *) "//input-method"; + xmlChar *key; + xmlNodeSetPtr nodeset; +#endif + int i; + xmlTextReaderPtr reader; + + reader = xmlReaderForFile (argv[1], "utf-8", 0); + xmlTextReaderRelaxNGValidate (reader, argv[2]); + while ((i = xmlTextReaderRead (reader)) == 1); + printf ("%d\n\n", i); + +#if 0 + doc = xmlParseFile (argv[1]); + if (! doc) + error_exit ("Invalid XML file: %s", argv[1]); + context = xmlXPathNewContext (doc); + result = xmlXPathEvalExpression (xpath, context); + if (! result) + error_exit ("Error in xmlXPathEvalExpression for: %s", (char *) xpath); + xmlXPathFreeContext (context); + if (xmlXPathNodeSetIsEmpty (result->nodesetval)) + error_exit ("Can't find the node: %s", (char *) xpath); + nodeset = result->nodesetval; + for (i = 0; i < nodeset->nodeNr; i++) + { + key = xmlGetProp (nodeset->nodeTab[i], "input-method-name"); + printf ("input-method-name: %s\n", key); + xmlFree (key); + key = xmlGetProp (nodeset->nodeTab[i], "language"); + printf ("langauge: %s\n", key); + xmlFree (key); + key = xmlGetProp (nodeset->nodeTab[i], "extra-id"); + if (key) + { + printf ("extra-id: %s\n", key); + xmlFree (key); + } + } + xmlXPathFreeObject (result); +#endif + exit (0); +}