开发者

How can we use EXSLT without downloading its source?

XSLTSL seems to claim that we can use EXSLT without downloading its source:

Import or include either the main stylesheet, or the stylesheet module you wish to use, directly from the library website; http://xsltsl.sourceforg开发者_运维百科e.net/modules/. The modules directory always contains the latest stable release.

I've tried this:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:import href="http://xsltsl.sourceforge.net/modules/string.xsl"/>
  <xsl:output method="text" indent="yes"/>

  <xsl:template match="/">
    <xsl:call-template name="str:to-upper">
      <xsl:with-param name="text">hello world</xsl:with-param>
    </xsl:call-template>
  </xsl:template>
</xsl:stylesheet>

But its not working. I don't seem to be able to use EXSLT without downloading its source.

Is there anyway to use EXSLT without downloading its source?


As is explaind in Using the library, you need to download it and

<xsl:import href="stdlib.xsl"/>

import it into your xslt script.

Btw, as an alternative you can also use the xslt translate function:

translate(value,"abcdefghijklmnopqrstuvwxyz","ABCBCDEFGHIJKLMNOPQRSTUVWXYZ")

It is a bit big to use in multiple places, but as long as you can place this in a template that shouldn't matter much.


You are not using the library correctly. Take a look at the instructions here.

Once you have downloaded the library, you need to:

1) Add an import to your xsl file:

<xsl:import href="string.xsl"/>

2) Add a namespace:

xmlns:str="http://xsltsl.org/string"

3) Call the template like this:

<xsl:template match="foo">
  <xsl:call-template name="str:to-upper">
    <xsl:with-param name="text">hello world</xsl:with-param>
  </xsl:call-template>
</xsl:template>

This will produce HELLO WORLD.

UPDATE:

No, you do not need to download the library locally. You can simply link to string.xsl using the full URL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜