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

Re: XSLT 1.1 comments -Examples please

Subject: Re: XSLT 1.1 comments -Examples please
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 15 Feb 2001 13:01:41 GMT
xalan xslt 1.1


> 1. A usage illustrating portability. Say get and re-format the date
>    in ecmascript, which could also use a java extension, as per DC comment.
>   - Regularly asked for? Reasonably 'safe'.


I just posted this off list to someone, may as well repost here (the
actual method and class names  don't work, but the basic
principle I hope is clear)


David




If you have a web form on which you get a date in the local language
settings and want to know if it is within a month of today, are you
really going to write a recursive xslt extension function to do that
or use a couple of lines to an extension language with built in locale
aware date handling? More than anyone I've argued for the benefits of
the functional approach, but I know which I would do. (Until XSLT n+1
when the feature gets added to XSLT)


Using xsl:script you can implement a date:number-of-days-between(a,b)
function that works for any XSLT 1.1 implementation that supports
javascript or vbscript or java. I don't think you can do that
in xslt 1.0 in any reasonable way.

in xslt 1.1 you make date: point of at any unique URI and then give 
multiple xsl:script to bind that URI to date related methods in whatever
target languages you are using.

in XSLT 1.0 you have to make date: point to a URI that is an xsl engine
specific prefix followed by a URI using the java class name, so it only
works on one engine, not even all the java ones.

xmlns:date="http://www.oracle.com.XSL/Transform/java/java.util.Date
(if java.util.date had a method of that name, which it probably doesn't) 

This is what xsl:script is trying to avoid.

It means I can use

<xsl:value-of select="date:number-of-days-between($a,$b)"/>

rather than the XSL 1.0 equivalent

<xsl:choose>
  <xsl:when test="function-exists('xt:number-of-days-between')">
    <xsl:value-of select="xt:number-of-days-between($a,$b)"/>
  </xsl:when>
  <xsl:when test="function-exists('saxon:number-of-days-between')">
    <xsl:value-of select="saxon:number-of-days-between($a,$b)"/>
  </xsl:when>
  <xsl:when test="function-exists('xalan:number-of-days-between')">
    <xsl:value-of select="xalan:number-of-days-between($a,$b)"/>
  </xsl:when>
  <xsl:when test="function-exists('msxsl:number-of-days-between')">
    <xsl:value-of select="msxsl:number-of-days-between($a,$b)"/>
  </xsl:when>

which is crazy, especialy given that the first three areeven using the
same class, thus the same code, just specified differently.



_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp

 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.