state of XSLT2/XPath2 or XQuery in CPython

Christof Hoeke cthedot at gmail.com
Wed Dec 26 17:04:51 EST 2007


Stefan Behnel wrote:
> Christof Hoeke wrote:
>> I was wondering if there is any way to use XSLT2 or maybe even XQuery
>> with "normal" CPython. Using Saxon/XSLT2 with Jython is no problem (I
>> have not tried Saxon.NET with IronPython but suspect no problem?) but I
>> could not find any way to use XSLT2 or XPath Features with CPython. All
>> the usual suspects 4suite or libxslt (via lxml) seem to have no support
>> yet. Is there any hope I oversaw something?
> 
> I wouldn't know any implementation. Are you looking for a specific feature?
> Using Python functions in XPath/XSLT might get you pretty close to XPath2.

Almost full XSLT2 Support (minus XML Schema support, IMHO not too useful 
part of XSLT2) would be the best as writing templates in a general 
templating lang as XSLT is great if you use the same ones in cross-lang 
systems which are e.g. usable in Java or Python environment.

Especially XPath Support with temporary trees (and not just fragments) 
is very useful (I know EXSLT is an option, but still not quite as good 
as XSLT2). Or stuff like sequences in XPAth2 simplifies development 
quite a bit (I think the following is possible, have not used it in the 
last weeks though):
	(a, b, c)[@att='123']

Or using sequences for ordering stuff like e.g.:

in XSLT1:
	<xsl:apply-templates select="a"/>
	<xsl:apply-templates select="b"/>

which in XSLT2 simply is:
	<xsl:apply-templates select="a, b"/>

I used the Python extension functions some years ago in Pyana and later 
in LXML which is great but these naturally very much depend on Python 
then...

I know XML and therefor also XSLT seem not the most favourite of tools 
in the Python community but for e.g. document based systems like CMS 
systems XML and XSLT is at least in my experience a great combination.

thanks
Christof



More information about the Python-list mailing list