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

RE: Global extension function

Subject: RE: Global extension function
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Sat, 22 Feb 2003 15:12:10 -0000
simple xalan extension functions
Using extension functions to get round the fact that XSLT doesn't allow
you to update variables is a really bad idea, save in exceptional
circumstances (for example, it would be OK if the counter is for
instrumenting your stylesheet, and the value of the counter doesn't
affect the result). You are abusing the language paradigm, and this
always leads to tears in the end. In your case, it has led to tears
already, because as you have discovered, extension functions are not
portable.

Find out why the stylesheet is using a counter, and replace it with
native XSLT constructs if you possibly can. The chances are that you can
achieve the required effect simply by using position() or xsl:number.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx  

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of TP
> Sent: 21 February 2003 16:40
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Global extension function
> 
> 
> I currently use xalan for my transformations.
> 
> I use 2 simple javascript functions that I have to because I 
> inherited them from <xsl:eval> days. I am planning on trying 
> other xslt processors but I cannot because I have been tied 
> down to using xalan. Looked up and found exslt, maybe this 
> can be used for my simple javascript functions.
> 
> The code is
> =======================
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:lxslt="http://xml.apache.org/xslt" 
> xmlns:counter="MyCounter" extension-element-prefixes="counter"
>     version="1.0">
> <lxslt:component elements="init incr" functions="read" 
> prefix="counter">
>   <lxslt:script lang="javascript">
>       var out=0;
>    var idi;
> 
>    function outID(){
>   var id="Out"+out;
>   idi=id;
>   out=out+1;
>   return id;
>     }
> 
>    function inID(){
>   return idi+"d";
>    }
> 
>    </lxslt:script>
>  </lxslt:component>
> ===========================================
> 
> Is there a quick solution to this such that I can include a 
> global kind of extension function and change processors as i 
> choose with the TRAX functionality.
> 
> Thanks
> 
> TP.
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 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.