xsl-list
[Top] [All Lists]

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

2007-07-17 14:27:27
Abel,

Thanks for thinking about this.  What I'm trying to do here is make
parts of one of my more complicated stylesheets work like this.

<xsl:if test="function is available">
call function to do custom output
</xsl:if>
<xsl:if test="function is not available">
default output
</xsl:if>

What I really want is the ability to define a function, and the
existence of the function alone causes the function to be used instead
of the default behaviour.

The stylesheet has lots of "logic" in it that I wouldn't want to have
to duplicate if all I really wanted to do was re-arrange the output,
or skin it differently.

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.

/John


On 7/17/07, Abel Braaksma <abel(_dot_)online(_at_)xs4all(_dot_)nl> wrote:
John McGowan wrote:
>
> When calling function-available() inside of a  use-when attribute it
> will never return true for a user defined function.  The specs pretty
> much say this exactly.

A new try, I had some coffee now ;)
I looked it up in my projects, because I remember I had a similar
problem. Actually, we included some helper functions for diagnosis when
in a debug environment. Instead of writing tedious xsl:if/when/otherwise
constructs, we defined several system properties, mainly to determine
the context (debug, analysis, test, production) the stylesheets were used.

Now we could write something like:

<xsl:value-of select="myfun:analyze-this(....)"
use-when="system-property('context') = 'debug'" />

Or, if you fancy that (not to everyone's taste), add it to you doctype
and do:

<xsl:value-of select="myfun:analyze-this(....)" use-when="&debug;" />


Not sure this (again) addresses your problem domain, but it could be
used to bring a (group of) stylesheet functions into the use-when and
can even be used on xsl:import etc.

Cheers,
-- Abel Braaksma

--~------------------------------------------------------------------
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>
--~--




--
/John

--~------------------------------------------------------------------
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>
--~--