This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Template repository (Was: Re: Re: namespace values)


Dimitre wrote:
> Once again, the most useful and immediately applicable result of
> this work would be to package the functions as a (pure XSLT)
> template library, that everybody could download directly from a web
> site and use immediately, without having to depend on specific
> vendour's decision to implement EXSL.
>
> This template library would "feed" EXSL with new functionality that
> is known to already have signifficant user acceptance.

OK, let's do this. I agree that it could feed [the core] EXSLT with
new functionality, in just the same way as a function repository
would.

I think it would be appropriate to use the same namespaces for the
templates as we use for the EXSLT modules, to have them under the same
umbrella, but I can see some people objecting that these templates
aren't extensions. On the other hand, the divisions between the
modules and the functionality of the various things are going to be
very similar and it would save having to declare lots of different
namespaces. For example, we could imagine having stylesheets with:

  <xsl:choose>
     <xsl:when test="function-available('math:min')">
        <xsl:value-of select="math:min($node-set)" />
     </xsl:when>
     <xsl:otherwise>
        <xsl:call-template name="math:min">
           <xsl:with-param name="node-set" select="$node-set" />
        </xsl:call-template>
     </xsl:otherwise>
  </xsl:choose>

It'll be fairly simple to change the exsl:function definitions into
similar templates to do roughly the same thing, so I'll do that.  One
thing, though - should I include within them shortcuts using
implementation-specific functions.  For example:

  <xsl:template name="math:min">
     <xsl:param name="node-set" select="/.." />
     <xsl:choose>
        <xsl:when test="function-available('saxon:min')">
           <xsl:value-of select="saxon:min($node-set)" />
        </xsl:when>
        ...
        <xsl:otherwise>
           <!-- XSLT recursive template -->
        </xsl:otherwise>
     </xsl:choose>
  </xsl:template>

The advantage is probably in terms of performance.  The disadvantage
is that saxon:min (etc.) might not behave exactly the same - for
example they might give different values when passed an empty node
set, so the template wouldn't give predictable behaviour under
different circumstances.

Dave, do you want to host this and the function repository? I can send
you the stylesheets and put in RDDL links from the EXSLT pages to
them. Or I can host them here.

Dimitre (and anyone else) - what are the other utility templates that
you feel would be useful?  Are there particular groups of them?  I
think that some string manipulation ones would be good - search and
replace, that kind of thing.

I really like Colin Muller's idea of basing the repository around
conformance tests.  If you have an idea for a template, then you
should also submit one or more examples of the:

  (a) source XML [if appropriate]
  (b) template call
  (c) desired output

If you have the template itself, so much the better. A while ago I
actually wrote an XSLT stylesheet to do use case testing
automatically. I'll tidy that up and make it available so that we can
use it.

As I've been thinking about the function repository, I've been
thinking about an XML structure to hold the pertinent information
about the functions; we need something similar for a template
repository as well.  If anyone would like to work on designing that
XML format, please stick up your hand.  It will make submissions a lot
easier if we have it.

Cheers,

Jeni

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



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]