xsl-list
[Top] [All Lists]

Re: the joy of breaking out from procedural/imperative programming style (was: Re: Peculiar Problem in .xsl file

2002-12-06 13:22:41
David,

I'm in 100 % agreement with you wrt to building functions as distinct
objects, and to the polluted aspect of XPath as a tool for the database
vendors.  To the latter point first, it seems to make a great deal more
sense to create modular type support rather than trying to impose PSVI (Post
Schema Validated Instance) into the grove/sequence model. Dates (and date
functions) would then fall into their own distinct namespace:

xpathTypeDef xmlns:date = "http://www.w3.org/XMLSchemaInstance/Date";

Xpath would then support a generic object type (I believe it already does,
for that matter) that could then work with the external constructors:

date:getMonth(date:new('2002-12-05'))

The same model could be used to add support for other extension functions in
a cohesive manner, and is not radically different from the way things are
done now, save that it gets the entire ugly data type model out of XPath and
into a user supported set of functionality where it belongs. You can use
Xpath 2 without PSVI perfectly well, and if you want the overhead of PSVI
you can add it yourself.

I think this feeds into the former point as well. If you treat a function as
a distinct object in its own right (a concept that is intrinsic to
declarative programming btw), then an external API should be able to be
written that supports functional manipulation. This would also go a long way
to making XPath a fully functional language in its own right -- there is
absolutely no reason why you could not do:

xpathTypeDef xmlns:fn = http://www.w3.org/Xpath2/Function

<xsl:variable name="seqence" select="let
$f:=fn:define($a,$b,$c,'union(intersect($a,$b),$c'),
fn:evaluate($f,(1,2,3),(2,3,4),(5))"/>

Of course this breaks the barrier of the no-post-evaluation mindset, which
I've always felt to be a silly restriction anyway.

I know, I know,  I'm preaching to the choir here.

-- Kurt

----- Original Message -----
From: "David Carlisle" <davidc(_at_)nag(_dot_)co(_dot_)uk>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Friday, December 06, 2002 11:44 AM
Subject: Re: the joy of breaking out from procedural/imperative programming
style (was: Re: [xsl] Peculiar Problem in .xsl file




#1 the function is data, but I'd have to do code generation to handle
    it as data and then execute the generated style sheet to execute
    the function.

It's not clear how you'd map some standard FP constructs like "map"
in that model. It may be possible (Dimitre's shown anything's possible
in this area if you really set your mind to it:-) but It seems to me
that functions as first class objects that could be passed as arguments
to other functions could have been added to the model. and would have
been a whole lot cleaner and more useful than 1001 functions for
handling gxmlQueryDateTypes.


#2 what do you mean when you say "shame about the rest of xpath2
    though"?

if I had a vote I wouldn't let xpath2 drafts pass on to
w3c recommendation status. I think it's been hijacked into a database
query language for typed data at the expense of its original use for
querying documents at greatly at the expense of loss of cross platform
portability. See other threads on this list and xml-dev in the last
couple of days.

 Aren't you one of the guys "in control" of that spec?
No. I'm just a user, I'm not on the working group.

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>