[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] function-available() test on stylesheet functions


Subject: Re: [xsl] function-available() test on stylesheet functions
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Tue, 17 Jul 2007 23:54:48 +0200

John McGowan wrote:

Right now, I think I may have to move all of my "default output" into functions that are defined by a file referenced by an xsl:import. Then I can successfully define an overriding function, when I want to customize the output.


As an alternative (thinking out loud here) you could do this:


<xsl:function name="my:function-available" as="xs:boolean">
 <xsl:param name="function-name" />
 <xsl:sequence select="$function-name = ('func1', 'func2'...)" />
</xsl:function>

and include that function always.

mmm, no, not really. I guess the situation is not that simple that it is all about a simple list of functions?

As an alternative (it could even be made part of FXSL, if not already), you can do the following:

<xsl:function name="my:function-available" as="xs:boolean">
<xsl:param name="function-name" />
<xsl:sequence select="$function-name = document(document('')/*/xsl:import/@href)/*/xsl:function/@name" />
</xsl:function>


but now you must place this in your principal document, and you need some extra logic if you want to recursively go through all imported / included documents.

If you do not place it in your principal document, you can use any of several techniques to pass it the name of the principal stylesheet.

None of these techniques give you perfect results though.

Cheers,
-- Abel


Current Thread