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)) > 100'> <a href='/photo/{id}-'> >>></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)}'> >>></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>
input :
<a>test</a>
output :
<a href="/photo/test-test_test"/>
Comments
Post a Comment