xsl-list
[Top] [All Lists]

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

2007-07-17 14:55:19
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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--