Re: [xslt] [PATCH][WIP] Using libexslt functions outside of XSLT

On Tue, Dec 16, 2008 at 04:39:15PM +0000, Martin (gzlist) wrote:
> Had a desire to use some exslt functions in libxml2 xpath expressions
> last month, attached is the patch I wrote. It's not really in a
> finished form, but works well enough, so thought I'd send it to the
> list rather than forget about it completely.
> In the grand tradition of bad example code without error checks or cleanup:
> 	xmlDocPtr doc = xmlReadDoc((xmlChar*)"<test>2008-11-22</test>", 0, 0, 0);
> 	xmlXPathContextPtr ctxt = xmlXPathNewContext(doc);
> 	exsltDateXpathCtxtRegister(ctxt, (xmlChar*)"date");
> 	{
> 		xmlXPathObjectPtr result =
> xmlXPathEval((xmlChar*)"date:seconds(/test)", ctxt);
> 		/* result->floatval is 1227312000.0 */
> 	}
> Useful when implementing the same functionality in the host language
> would be difficult and error prone.

  Bahh, it's not a bad idea, I have fixed a couple of things and pushed

    thanks :-)


Daniel Veillard      | libxml Gnome XML XSLT toolkit
daniel veillard com  | Rpmfind RPM search engine | virtualization library

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