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

Writing extension functions (& elements)

Subject: Writing extension functions (& elements)
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 31 Jan 2001 11:22:54 +0000
lxslt script
I said:
> : Yes, but be aware that Javascript isn't incorporated into XSLT until
> : XSLT 1.1 or unless you're using MSXML. 

Eugene pointed out:
> The binding mechanism wasn't standardized in XSLT 1.0, same as Java,
> but there are several implementations besides MSXML... Unicorn XSLT
> processor has one, for example, and I believe Xalan does too.

Eugene's absolutely right, of course, although I can't see any way in
Unicorn XSLT to include Javascript *in the stylesheet itself* - I
think you have to import a script using obj:import (obj being bound to
http://www.unicorn-enterprises.com/XSLT/Extensions/ECMAScript/1.0) and
then can call a function in that script either with function syntax like
obj:call(object, function, arguments*) or with element syntax.  I'd be
pleased to be corrected - this is just what I've gathered from a quick
read of the documentation.

Xalan-Java has some Really Cool Stuff that enables you to define not
only your own functions, but also your own elements, actually within a
stylesheet. You can also use loads of different languages to define
them (though not, sadly, XSLT ;)

Using a Javascript function in XSLT when you're using Xalan involves
the same kind of preparatory steps as using msxsl:script:

(a) declaring the Xalan namespace (http://xml.apache.org/xslt) - for
some reason the Xalan documentation uses the prefix lxslt
(b) declaring your own namespace (e.g. http://www.foo.com/)
(c) declaring the namespace prefixes you use as extension element
prefixes

You need to use two extension elements to define functions when using
Xalan: lxslt:component and lxslt:script.  The equivalent of the
msxsl:script element:

<msxsl:script language="javascript"
              implements-prefix="foo">
   function retrieveData() {
      return true;
   }
</msxsl:script>

is:

<lxslt:component prefix="foo" functions="retrieveData">
   <lxslt:script lang="javascript">
      function retrieveData() {
         return true;
      }
   </lxslt:script>
</lxslt:component>

While msxsl:script will disappear when XSLT 1.1 is finalised and
supported, it looks as though lxslt:component and lxslt:script will
still have a place because they allow you to write your own extension
elements as well.  Does anyone have any experience with writing
extension elements in Xalan that they could share?

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 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.