xsl-list
[Top] [All Lists]

RE: Portability function-available tips

2004-01-09 05:04:26
 > Dimitre has a version of msxml that supports exsl,
 > alternatively I believe you can put in an msxsl script 
 > element that will be ignored by other processors but which 
 > implements exsl:node-set (essentially just needs to be an 
 > identity function)
 > 
 > David
 
 Ahhh excellent - exactly the kind of thing I was looking for, 
 thanks David

Hmmm, maybe it wasn't :)

Or at least, I can't see how to take advantage of it.

As an example, I currently build a temporary tree and convert it to a
node-set: 

<xsl:variable name="foo-rtf"> 
  <xsl:apply-templates mode="build"/> 
</xsl:variable> 
<xsl:variable name="foo" select="exsl:node-set($foo-rtf)"/> 

I then use that variable in several places by using:

<xsl:for-each select="$foo"> 
  <xsl:apply-templates/> 
</xsl:for-each> 

The only way I can see of making the stylesheet portable is to replace
all occurances of the above for-each, with this choose/when:

<xsl:choose> 
  <xsl:when test="function-available(msxml:node-set)"> 
    <xsl:for-each select="msxml:node-set($foo-rtf)"> 
      <xsl:call-template name="foo-template"/> 
    </xsl:for-each> 
  </xsl:when> 
  <xsl:when test="function-available(exsl:node-set)"> 
    <xsl:for-each select="exsl:node-set($foo-rtf)"> 
      <xsl:call-template name="foo-template"/> 
    </xsl:for-each> 
  </xsl:when> 
  <xsl:otherwise> 
    <xsl:call-template name="error"/> 
  </xsl:otherwise> 
</xsl:choose> 

Not only that, but to avoid code duplication I need to separate out the
body of the for-each into a named template - which is even more code.

How can I integrate the msxml:script idea to avoid using
function-available?

This is simply not necessary -- just use exslt:node-set().

At present I am working with the following 9 XSLT processors all of which
implement exslt:node-set():

  MSXML4 (3rd party implementation -- download at:
                                      http://sf.net/projects/fxsl)

  .Net xsltTransform 
(3rd party implementation -- download at:
http://www.gotdotnet.com/Community/Workspaces/Workspace.aspx?id=201eb290-5bf0-4452-9bf7-d21d39268f36
)

  Saxon6.5.3

  Saxon 7.8

  JD

  XalanJ 2.4.1 and later

  XalanC 1.5

  xsltProc

  4xslt

These are just the 9 XSLT processors I'm working with on a daily basis.
Probably there are even more processors with EXSLT support.


(ps is this the way that everyone keeps there stylesheet portable?)

As noted above, just using exslt:node-set() is what allows me to develop
and support a single version of FXSL.


Dimitre Novatchev.
FXSL developer

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html



__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list