Using xsl:key to store result of boolean expression

Posted by hielsnoppe on Stack Overflow See other posts from Stack Overflow or by hielsnoppe
Published on 2012-12-20T10:39:49Z Indexed on 2012/12/20 11:03 UTC
Read the original article Hit count: 288

Filed under:
|
|

In my transformation there is an expression some elements are repeatedly tested against. To reduce redundancy I'd like to encapsulate this in an xsl:key like this (not working):

<xsl:key name="td-is-empty" match="td" use="not(./node()[normalize-space(.) or ./node()])" />

The expected behaviour is the key to yield a boolean value of true in case the expression is evaluated successfully and otherwise false. Then I'd like to use it as follows:

<xsl:template match="td[not(key('td-is-empty', .))]" />

Is this possible and in case yes, how?

© Stack Overflow or respective owner

Related posts about xpath

Related posts about xslt-1.0