[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] [ANN] Saxon/C - Saxon for the C/C++ and PHP platforms

Subject: Re: [xsl] [ANN] Saxon/C - Saxon for the C/C++ and PHP platforms
From: "Tony Graham" <tgraham@xxxxxxxxxx>
Date: Fri, 29 Nov 2013 09:59:58 -0000 (GMT)

On Thu, November 28, 2013 8:32 pm, Michael Kay wrote:
>> So we need to create a libxslt2 bridge now right?
> You mean in terms of bridging the API? We haven't really explored what's
> feasible yet in terms of libxslt2 and libxml cooexistence. At the moment
> if you've got data in a libxml tree you have to serialize and reparse to
> get it into Saxon. I don't know if we'll ever be able to do better than
> that; I suspect the overheads of doing it this way are lower than the
> overheads of accessing the libXML tree node-by-node from the Java
> environment, but we'll find out in due course.

The top-level API for libxslt is at

The top level of the top-level API would be xsltApplyStylesheet [1]:

xmlDocPtr	xsltApplyStylesheet	(xsltStylesheetPtr style,
					 xmlDocPtr doc,
					 const char ** params)

xsltApplyStylesheetUser [2]:

xmlDocPtr	xsltApplyStylesheetUser	(xsltStylesheetPtr style,
					 xmlDocPtr doc,
					 const char ** params,
					 const char * output,
					 FILE * profile,

xsltRunStylesheet [3]:

int	xsltRunStylesheet		(xsltStylesheetPtr style,
					 xmlDocPtr doc,
					 const char ** params,
					 const char * output,
					 xmlSAXHandlerPtr SAX,
					 xmlOutputBufferPtr IObuf)

and xsltRunStylesheetUser [4]:

int	xsltRunStylesheetUser		(xsltStylesheetPtr style,
					 xmlDocPtr doc,
					 const char ** params,
					 const char * output,
					 xmlSAXHandlerPtr SAX,
					 xmlOutputBufferPtr IObuf,
					 FILE * profile,
					 xsltTransformContextPtr userCtxt)

A very unscientific search of code.ohloh.net showed these comparative
popularities in C code:

xsltApplyStylesheet [5]:      397,605
xsltApplyStylsheetUser [6]: 2,248,197
xsltRunStylesheet [7]:      1,113,553
xsltRunStylesheetUser [8]:  2,659,677

The two main ways to get a xsltStylesheetPtr would be
xsltParseStylesheetDoc [9] and xsltParseStylesheetFile [10], with
comparative popularities:

xsltParseStylesheetDoc [11]:    844,622
xsltParseStylesheetFile [12]: 4,330,439

By way of comparison, newXsltCompiler gets 7,274,828 hits in Java code [13].

> From a first glance, the libxslt2 API is very closely coupled with libxml,
> which makes it difficult to reproduce directly; in addition, my experience
> is that an API designed for XSLT 1.0 doesn't easily scale outwards to
> handle XPath 2.0/3.0, XSLT 2.0/3.0, XQuery 3.0, and XSD 1.1, plus
> pipelines mixing all of the above.

I don't think you could make a Saxon/C stylesheet look like a
xsltStylesheetPtr, but it does appear that most xsltStylesheetPtr are made
straight from a file or an existing xmlDoc, so I am back to my assertion
that you could get a long way by the XSLT processor just producing and
consuming xmlDoc even if, as you say, you have to reserialise from and to
the xmlDoc to get things to work.


Tony Graham                                   tgraham@xxxxxxxxxx
Consultant                                 http://www.mentea.net
Mentea       13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
 --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
    XML, XSL-FO and XSLT consulting, training and programming
       Chair, Print and Page Layout Community Group @ W3C

[3] http://www.xmlsoft.org/XSLT/html/libxslt-transform.html#xsltRunStylesheet

Current Thread