Re: functions and XSLT
Hi Dave, > I understand that people are saying there is a large distinction between > providing a return value and creating a result-tree-fragment. I just > don't see that two types of subroutine are required to allow these roles > to be distinguished -- to me, the latter issue can and should be > orthogonal to the former. Sorry, I don't follow you here, could you please make an example on how you would go about implementing, say, an exsl:intersection function with named templates. > The unit of subroutine should be focused upon > computing the appropriate information and returning it. Exactly _how_ > that information is used later -- whether that be within an XPath > expression, or written out as a tree fragment -- need not (and > therefore, should not!) depend upon the internal definition of the > subroutine, but rather only upon the context in which the subroutine is > referred to. If you call an extension function defined by exsl:function, fx:define or xsl:script, you get an XPath value as the result. The calling side has no idea or dependency what so ever on how that value was computed. The resulting value can then be used at the callers discretion, still with no knowledege about how or even when that value was created. I don't see what dependency you are refering to. > > Regarding source nodes, the inability to return a source-tree-fragment > reflects the lack of a construct allowing the construction of closures, > rather than an inherent, deep-seated flaw in the template mechanism. I can't remember anyone, recently involved in the discussion about user defined extension functions, arguing that there is a deep-seated flaw in the template mechanism. Templates are designed for a very specific purpose: creating result tree fragments, and they are good at it. The discussion about functions in XSLT has been around implementing extension functions callable from within XPath expressions. Indeed, using plain named templates as extension functions has been suggested at some point, but I'm pretty sure that the consensus is that that approach is far too limited (for reasons mentioned in the previous answer, for example). Closures are mainly about variable bindings. How do you mean they can affect the types of values that can result from a call to an extension function? Cheers, </David> David Rosenborg Pantor Engineering AB XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format