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
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
[email protected] | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
_______________________________________________
xslt mailing list, project page http://xmlsoft.org/XSLT/
[email protected]
http://mail.gnome.org/mailman/listinfo/xslt