xslt - Is it possible to call a function inside an attribute? -


i can't find out how 1 can call extension function in code that:

<xsl:if test='string-length(normalize-space(body)) &gt; 100'>     <a href='/photo/{id}-'> &gt;&gt;&gt;</a><br/> </xsl:if> 

i need add call foo:translit(human_url) function after '{id}-' result read '/photo/{id}-{transliterated_part}', there seems no syntactical correct way so!

yes, possible. casually call function wrapped in curly braces, :

<a href='/photo/{id}-{foo:translit(human_url)}'> &gt;&gt;&gt;</a> 

here demo using user-defined function foo:upper-lower(), return upper-case , lower-case version of received parameter, separated underscore :

<?xml version="1.0" encoding="utf-8" ?> <xsl:transform exclude-result-prefixes="foo xs" xmlns:foo="bar" xmlns:xs="http://www.w3.org/2001/xmlschema" xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="2.0">     <xsl:output encoding="utf-8" indent="yes" />      <xsl:function name="foo:upper-lower" as="xs:string">       <xsl:param name="input" as="xs:string"/>       <xsl:sequence select="concat(upper-case($input),'_',lower-case($input))"/>     </xsl:function>      <xsl:template match="a">       <a href="/photo/{.}-{foo:upper-lower(.)}"></a>     </xsl:template> </xsl:transform> 

xsltransform.net demo

input :

<a>test</a> 

output :

<a href="/photo/test-test_test"/> 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -