[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: mapping (Was: Re: Re: . in for)

Subject: RE: mapping (Was: Re: Re: . in for)
From: Joerg Pietschmann <joerg.pietschmann@xxxxxx>
Date: Wed, 09 Jan 2002 14:39:40 +0100
xslt mapcar named template
> J.Pietschmann wrote:
> We could then write select ='map(xf:lower-case, $departments)'.

Well, there is a major problem: the function must take exactly
one parameter. If hou have a my:grumbulate function which takes
two parameters and you want tor grumbulate a sequence, you'll have
to write a projection function first. While this is already a
significant inconvenience, it gets worse if say the second parameter
is not a constant value:

 <xsl:template match="stuff">
   <xsl:parameter name="grumbulation-value"/>
   <xsl:copy-of select="map(my:grumbulation-projektor,stuff-childs)"/>

How to pass the grumbulation-value? Two possible solutions:
- Local function definitions:
 <xsl:template match="stuff">
   <xsl:parameter name="grumbulation-value"/>
   <xsl:function name="my:grumbulation-projektor">
      <xsl:param name="arg"/>
      <xsl:item select="my:grumbulation($arg,$grumbulation-value)"/>
   <xsl:copy-of select="map(my:grumbulation-projektor,stuff-children)"/>
- Dynamically scoped variables

I don't like either very much.

Another possibility is having map() take a variable number of arguments,
the first is the function, all following sequences which supply the
parameters in parallel (like in most LISP variants)

Specifying the exact behaviour of the map function, especially for
the cases of having sequences of different length supplied, is tedious
but it should be possible to lift it almost literally from some LISP

Oh no, i just saw the problem with using QNames for passing functions:
they are already XPath expressions for accessing nodes :-/
Let's have a function for converting Strings which are actually QNames
of functions to function objects, like the well known LISP 'function
(I mean as in (mapcar (function cdr) list) ).
This means writing
The argument of such a generic function object constructor could be made
a literal for the sake of optimizations. I think however some people will
consider the standard crippled if they can't read their function names
from the source XML :-)


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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.