Re: [xslt] extension



>   Well, I think it's historical, the initial API allowed only individual
> function registration, and the module support was added because people
> needed to have some context (like a database connection) persistance
> across call to extensions.

Ok, fair enough.

>   Actually is you have good example of doing some module extensions
> that's something which should be added to the documentation, like the
> examples for libxml2 http://xmlsoft.org/examples/index.html
> doing something similar for libxslt/libexslt would be useful, probably
> not very hard based on the existing libxml2 indexing code.

Ok, I might look at doing that if I get time.

>   If you have good examples (didactic and standalone) I would appreciate
> contributions :-)

My code probably isn't much use as an example of this kind, since it's
just a collection of similar (date handling) functions grouped into a
module, rather than functions which share any resources. Sadly it's also
fairly tightly tied to some propriatory code owned by the company I work
for. Sorry about that, if I come up with any examples that are more useful
to others, I'll mail them to the list.

I've attached a small patch to allow xsltDebugExtensions() to display all
extension modules (as well as elements and functions), since elements or
functions which are in a module registered with xsltRegisterExtModule()
don't show up otherwise.

Thanks again,

Steve
*** extensions.c	Wed Oct 15 16:26:01 2003
--- extensions.c.new	Wed Feb 18 12:10:08 2004
***************
*** 1621,1626 ****
--- 1621,1636 ----
  	fprintf(output,"{%s}%s\n",URI,name);
  }
  
+ static void
+ xsltDebugDumpExtModulesCallback(void* function ATTRIBUTE_UNUSED,
+ 	                        FILE *output, const xmlChar* URI,
+ 				const xmlChar* not_used ATTRIBUTE_UNUSED,
+ 				const xmlChar* not_used2 ATTRIBUTE_UNUSED) {
+ 	if (!URI)
+ 		return;
+ 	fprintf(output,"%s\n",URI);
+ }
+ 
  /**
   * xsltDebugDumpExtensions:
   * @output:  the FILE * for the output, if NULL stdout is used
***************
*** 1645,1650 ****
--- 1655,1666 ----
  		fprintf(output,"\nRegistered Extension Elements:\n");
  		xmlHashScanFull(xsltElementsHash,(xmlHashScannerFull)xsltDebugDumpExtensionsCallback,output);
   	}
+ 	if (!xsltExtensionsHash)
+ 		fprintf(output,"\nNo registered extension modules\n");
+ 	else {
+ 		fprintf(output,"\nRegistered Extension Modules:\n");
+ 		xmlHashScanFull(xsltExtensionsHash,(xmlHashScannerFull)xsltDebugDumpExtModulesCallback,output);
+  	}
  
  }
  


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