Re: [xsl] Re: Re: The Perils of Sudden Type-Safety in XPath 2.0

Subject: Re: [xsl] Re: Re: The Perils of Sudden Type-Safety in XPath 2.0
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Thu, 20 Feb 2003 00:18:12 -0800 (PST)
--- "Kurt Cagle" <cagle@xxxxxxxxx> wrote:
> Dmitre,
> I'm inclined to agree with Michael on this. I think that the type
> mechanisms
> do add (perhaps an unreasonable) burden in verbosity, but that is
> more
> than
> offset by the ability to move a significant amount of the heavy
> lifting
> into
> XPath through <xsl:function>
> <xsl:function name="fmt:bangPad">
>     <xsl:param name="expr"/>
>     <xsl:result
> select="string-pad('!',xs:string(xs:integer($expr)))"/>
> </xsl:function>
> <xsl:value-of select="fmt:bangPad(@risk * @severity)"/>


This is a nice example!

But the truth probably lies somewhere in-between. 

There will be cases when many functions are used in a stylesheet, but
most of them are used *only once*. Providing a wrapper xsl:function for
every such function will increase the length of the code significantly.

One can argue that probably third-party libraries of such wrappers will
be available, so one will need only to xsl:import them.

But if this happens, this would mean that something in the design of
the standard functions was not OK.

Let's return to the example of string-pad(). Would it not be a better
decision to allow any number as the type of the second argument?

Then people would have to use the familiar conversion number(x) and
this would facilitate the transition to XSLT2 for most of the XSLT1
folks. Let's face it -- most people (me included) do not feel
comfortable that they must use schemas with XSLT2. Even declaring the
namespace and using the prefix can be a considerable psychological
burden (sorry for going into Jeni's territory).

This will also address Chuck's concern that the XSLT2 programmer will
have to do an "awful lot of cross-referencing to grok it all (go look
at the XQuery function and operator spec, then go look at XPath, then
go back to the XSLT spec to see how to use something else)".

And let's not try to mislead anyone that xs:integer was chosen because
it was the exact type for this function -- it isn't the exact type.
Anyone can still pass a negative integer to string-pad() and no static
type-checking will help.

So, the authors of XQ/XP functions/operators decided to draw the line
somewhere, but should have drawn it on allowing any number, not just

Probably we need to start some real work using Saxon 7.x and have a
separate forum for discussing the real-work experience.

I also will join the people appreciating highly the huge work done by
Mike Kay and his advice on XSLT2 (and not least having to deal with
people like myself :o))


Dimitre Novatchev. -- the home of FXSL

Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more

 XSL-List info and archive:

Current Thread