I am working on an XSLT translation that has a single,
complicated boolean function appear in multiple loops
(and therefore in multiple places within the XSLT
document). In order to make the document more robust,
specifically to avoid a future edit that updates the
boolean
test in some of the locations it appears but
misses some others, I'd like to have a single declaration
of the boolean test that I can call in the various locations.
I attempted to do this using an xsl:variable:
<xsl:variable name="MatchSelect">not(./Name = preceding::AA_Entry/child::Name) and (./Name = following::AA_Entry/Name)</xsl:variable>
then referencing the variable in another location
as the test attribute of an xsl:if:
<xsl:if test="$MatchSelect">
but what I find is that the xsl:if conditional
ends up matching everything (the conditional
always evaluates to true).
Can anyone help me by telling me this approach definitely
won't work, that this should work and I must be making some
kind of syntax/dereferencing error (troubleshooting suggestions
welcome!), or that there's another approach to realizing this
functionality?