How can we use EXSLT without downloading its sourc

2019-07-08 02:50发布

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.sourceforge.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?

标签: xml xslt exslt
2条回答
我只想做你的唯一
2楼-- · 2019-07-08 03:25

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.

查看更多
乱世女痞
3楼-- · 2019-07-08 03:42

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.

查看更多
登录 后发表回答