/* To compile:
gcc -o tester  -I /usr/include -I /usr/include/libxml2 -I /usr/include/libxslt -I /usr/include/libexslt  -lc -lm -lpthread -L/usr/lib/ -lexslt -L/usr/lib/ -lxslt -L/usr/lib/ -lxml2 tester.c

To run:

Create an XML input file with contents:
<?xml version="1.0"?>
<a>blah</a>

and give it a name like "foo with space and ^.xml"

Run:
./tester `pwd`/"foo with space and \^.xml"

Observed output (where "A" is the full path, assuming it contains
no spaces or other troublesome characters):
Original filename:
A/foo with space and ^.xml
xmlReadFile()->URL:
A/foo%20with%20space%20and%20%5E.xml

The problem is that the value of the URL field is neither a
valid URL nor a valid name for the supplied file.

*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxslt/xslt.h>

static int options = XSLT_PARSE_OPTIONS;

int main(int argc, char **argv) {
   xmlDocPtr doc;
   char *filename = argv[1];
   doc = xmlReadFile(filename, NULL, options);
   printf("Original filename:\n%s\nxmlReadFile()->URL:\n%s\n",
	  filename,
	  doc ? (char *) doc->URL : "<parse failed>");
}
