Subject: RE: [xsl] object-oriented XSL From: martin@xxxxxxxx Date: Sun, 25 Aug 2002 16:01:19 +0000 (GMT) |
On Fri, 23 Aug 2002, Hunsberger, Peter wrote: > There are times I wish that XSLT did have a better OO model, but that is in > the way that includes and imports work. XSLT 2 with the ability to have > multi-modal templates may solve some more of this requirement. However, > there are still some gaps. I'm still at a loss as to what your hoping to > achieve beyond what existing languages can do? what if defining a new XPath function was as easy as writing a named template: <xsl:function name="fib"> <!-- calculates fibonacci numbers recursively --> <xsl:param name ="n" /> <xsl:choose> <xsl:when test ="$n <= 2" > <xsl:value-of select="1" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="fib($n - 1) + fib($n - 2)"/> </xsl:otherwise> </xsl:choose> </xsl:function> and what if you could define types and associate functions with them, wouldn't that be pretty cool? XPath would have to be extended to allow type function invokation, eg: <xsl:type name="User"> <xsl:variable name="name"/> <xsl:function name="User"> <!-- this is a constructor, it is defined as a global XPath function and returns a User object --> <xsl:param name="name"/> </xsl:function> <xsl:function name="speak"> <!-- this is a type function, can only be invoked on an object of type User --> <xsl:value-of select="concat('Hello, my name is ',$name)"/> </xsl:function> </xsl:type> <xsl:variable name="newUser" select="User('Fred')"/> <xsl:value-of select="$newUser.speak()"/> <!-- uses '.' for type function invokation --> quickly this takes us far from what XSLT is and what it does, but it's exactly the sort of language possibilities that i would like to explore further. for the oo to work well it would have to be procedural, not functional or declarative, and allow simple things like variable reassigning and side-effects. add to this non-XSLT dynamically typed language a bit of function overloading, (multiple?) inheritance, polymorphism and module building constructs and i think that you really got something to kick .NET and C# back down the hole they came from. want to write XML web services? write them in XML! (then transform the result using XSLT!!) /m (can't help but get political at times) XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] object-oriented XSL, Hunsberger, Peter | Thread | Re: [xsl] object-oriented XSL, Jeni Tennison |
Re: [xsl] object-oriented XSL, Jeni Tennison | Date | RE: [xsl] object-oriented XSL, martin |
Month |