Re: [xslt] Functions for fetching file list
- From: crispin iinet net au
- To: xslt gnome org
- Subject: Re: [xslt] Functions for fetching file list
- Date: Wed, 18 Jul 2001 11:53:37 +0800
On Tue, Jul 17, 2001 at 08:51:54AM +0000, Matt Sergeant wrote:
> On 17 Jul 2001 12:21:53 +0800, crispin@iinet.net.au wrote:
> > Hi,
> >
> > I need during processing an XML document with an XSLT sheet to gather a list of all the files that were needed in the process.
> >
> > If you use xsltproc like this
> >
> > xsltproc -v test.xsl welcome.xml
> >
> > in the output you get the following lines
> >
> > parsed 3 templates
> > Initializing keys on welcome.xml
> > Registering global variables
> > Registering global variables from test.xsl
> > Registering global variables from theme.xsl
> >
> > Which are the three files used. xsltproc uses xsltSetGenericDebugFunc(stderr, NULL); to pipe that info to stderr.
> >
> > I would like however, to get this information more directly. What is the best way of doing this?
>
> Create your own input callbacks, and get the information from there.
Input callbacks, eh?
I looked through the xslt and xml API documentation (terribly brief) and the only thing that matched was in libxml in xmlIO. A function xmlRegisterInputCallbacks.
So I tried the following code...
----------------------------------------------------
int MatchCallback(const char *filename)
{
printf("matchCallback(%s)\n",filename);
return 0;
}
void *OpenCallback(const char *filename)
{
printf("openCallback(%s)\n",filename);
return NULL;
}
int ReadCallback(void *context, char *buffer, int len)
{
printf("readCallback(%d,%s,%d)\n",(int)context,buffer,len);
return 1;
}
void CloseCallback(void *context)
{
printf("closeCallback(%d)\n",(int)context);
}
void InstallCallbacks()
{
xmlRegisterInputCallbacks(MatchCallback,OpenCallback,ReadCallback,CloseCallback);
}
----------------------------------------------------
Just to see what they would do. Then my processing code went...
----------------------------------------------------
xsltStylesheetPtr ss = NULL; /* will hold the stylesheet */
xmlDocPtr doc, res; /* will hold the xml and the result */
xmlOutputBufferPtr outputxml=NULL;
InstallCallbacks(); /* INSTALLS THE CALLBACKS HERE */
/* generate html. Store in buffer. Store a list of contributed files in filelist */
printf("1\n");
outputxml=xmlAllocOutputBuffer(NULL);
printf("2\n");
xmlSubstituteEntitiesDefault(1); /* perform entity substitution */
xmlLoadExtDtdDefaultValue = 1; /* load external entity subsets */
printf("3\n");
/* load files and generate output */
ss = xsltParseStylesheetFile((const xmlChar *)xslfile);
printf("4\n");
doc = xmlParseFile(xmlfile);
printf("5\n");
res = xsltApplyStylesheet(ss, doc, NULL);
printf("6\n");
xsltSaveResultTo(outputxml, res, ss);
printf("7\n");
/* clean up */
xsltFreeStylesheet(ss);
xmlFreeDoc(res);
xmlFreeDoc(doc);
printf("8\n");
/* now outputxml holds the resultant html */
xmlOutputBufferClose(outputxml);
----------------------------------------------------
However it appears none of my callbacks were called. I got no output from them at all. So either...
1) xmlRegisterInputCallbacks is not the function I want
or
2) I'm calling xmlRegisterInputCallbacks incorrectly or implementing the callbacks incorrectly
Any help is appreciated. I need some more info on what API function calls are the ones I want. Either that or point me to some example code, or tute or docs.
Thanks everyone.
Crispin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]