
Hello, are XSLT functions supported in lxml (I am now using 4.1 lxml)? For example I have: <xsl:function name="foo:prettyIndent"> <xsl:param name="s"/> <xsl:for-each select="1 to 4*($s - 2)"> </xsl:for-each> </xsl:function> And then use it in "select" statements in temaplates. When I use my function in the select statement, I get "XSLTParseError: Invalid expression" - so I suspect that this feature is not supported in lxml. Regards, remek

Hi,
If I remember correctly xslt functions are an XSLT 2 feature. lxml supports XSLT 1 only, through libxml2/libxslt. However, exslt extensions *are* supported by libxslt so you might want to check if exslt functions are included in this exslt support (see e.g. http://www.jenitennison.com/xslt/exslt/functions/). Or you could implement your functions in Python and make them available in XSLT (http://lxml.de/extensions.html). Holger Landesbank Baden-Wuerttemberg Anstalt des oeffentlichen Rechts Hauptsitze: Stuttgart, Karlsruhe, Mannheim, Mainz HRA 12704 Amtsgericht Stuttgart

<xsl:function> and this particular XPath expression -- (1 to 4 * ($s - 2) -- are XSLT 2.0 features. libxslt supports only XSLT 1.0 and EXSLT. It does support EXSLT functions though, so you can start with that: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="whatever" xmlns:exf="http://exslt.org/functions" extension-element-prefixes="exf"> <exf:function name="foo:prettyIndent"> <xsl:param name="s" /> <!-- not sure how to easily get that sequence though; I'd rethink the approach. --> <exf:result select="..." /> </exf:function></xsl:stylesheet> Kind regards, Mikhail On 11/15/2017 4:39 PM, P. Remek wrote:
-- Mikhail Edoshin mikhail.edoshin@gmail.com Skype: mikhail_edoshin (GMT+3)

Hi,
If I remember correctly xslt functions are an XSLT 2 feature. lxml supports XSLT 1 only, through libxml2/libxslt. However, exslt extensions *are* supported by libxslt so you might want to check if exslt functions are included in this exslt support (see e.g. http://www.jenitennison.com/xslt/exslt/functions/). Or you could implement your functions in Python and make them available in XSLT (http://lxml.de/extensions.html). Holger Landesbank Baden-Wuerttemberg Anstalt des oeffentlichen Rechts Hauptsitze: Stuttgart, Karlsruhe, Mannheim, Mainz HRA 12704 Amtsgericht Stuttgart

<xsl:function> and this particular XPath expression -- (1 to 4 * ($s - 2) -- are XSLT 2.0 features. libxslt supports only XSLT 1.0 and EXSLT. It does support EXSLT functions though, so you can start with that: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="whatever" xmlns:exf="http://exslt.org/functions" extension-element-prefixes="exf"> <exf:function name="foo:prettyIndent"> <xsl:param name="s" /> <!-- not sure how to easily get that sequence though; I'd rethink the approach. --> <exf:result select="..." /> </exf:function></xsl:stylesheet> Kind regards, Mikhail On 11/15/2017 4:39 PM, P. Remek wrote:
-- Mikhail Edoshin mikhail.edoshin@gmail.com Skype: mikhail_edoshin (GMT+3)
participants (3)
-
Holger Joukl
-
Mikhail Edoshin
-
P. Remek