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

Portability function-available tips

Subject: Portability function-available tips
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Thu, 8 Jan 2004 15:56:35 -0000
msxml node set
Hopefully someone can help me out here, otherwise Ive got a lot of
coding to do...

Throughout a stylesheet I have node-sets created in the form:

  <xsl:variable name="foo-rtf">
  ..
  </xsl:variable>
  <xsl:variable name="foo" select="exsl:node-set($foo-rtf)"/>

Then I reference the node-sets using:

  <xsl:for-each select="$foo">
    do whatever
  </xsl:for-each>


Now I have to ensure the stylesheets work with Msxml 4.0 as well, which
doesn't support exsl out of the box.  The only way I can see of doing
this is to replace each occurance of:

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

With a choose/when using function available, with the body of the
for-each in a named template:

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

This is bloating the code out, making it more difficult to read, and
just feels wrong.

Has anyone got any tips/tricks in this situation?

Is it possible to do the test in a single place, along the lines of:

<xsl:variable name="foo-node-set">
  <xsl:choose>
    <xsl:when test="function-available(msxml:node-set)">
    
      <xsl:copy-of select="msxml:node-set($foo-rtf)"/>

    </xsl:when>
    <xsl:otherwise>

      <xsl:copy-of select="exsl:node-set($foo-rtf)"/>

    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>

...but of coure this still leaves you with a RTF.

cheers
andrew

 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.