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

RE: object-oriented XSL

Subject: RE: object-oriented XSL
From: martin@xxxxxxxx
Date: Sun, 25 Aug 2002 16:01:19 +0000 (GMT)
xsl fibonacci
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 &lt;= 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.