XSLT版本1 URL编码 [英] XSLT version 1 URL encoding

查看:111
本文介绍了XSLT版本1 URL编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XSLT版本1中是否有URL编码功能? 我需要类似于javascript中的encodeURIComponent函数的东西吗?

Is there a URL encoding function in XSLT version 1? I need something similar to encodeURIComponent function in javascript?

由于XSLT已应用于Sharepoint页面,因此我正在使用.NET平台,因此这是不可能的.有没有一种方法可以编码此购买,从而在XML中调用javascript编码函数(以下代码段):

Seeing as this is not possible as I'm using .NET platform as the XSLT is applied to a Sharepoint page. Is there a way to code this buy calling the javascript encode function within the XML, snippet below:

<xsl:template name="BuildLink">
    <xsl:param name="PrimarySubject" />
    <xsl:text>?PrimarySubject=</xsl:text>
    <xsl:value-of select="$PrimarySubject" />
</xsl:template>

谢谢

推荐答案

您可以使用XSLT中嵌入的JScript ...

you can use JScript embedded in XSLT ...

<msxsl:script language="JScript" implements-prefix="custom">
function uriencode(string) {
 return encodeURIComponent(string);
}
</msxsl:script>

并像custom:uriencode( url_to_encode )

首先,您需要定义名称空间,方法是将<xsl:stylesheet ...标签添加到 xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:custom="http://youdomain.ext/custom"

You will first need to define the namespace though by adding to the <xsl:stylesheet ... tag the xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:custom="http://youdomain.ext/custom"

[更新]

[update]

我为自定义名称空间输入的网址可以是任何内容..

the Url i put for the custom namespace could be anything .. it is just a unique identifier..
(the link concludes that it is less confusing if you do not use a url as the identifier..)

[udpdate 2]

[udpdate 2]

添加了一些信息.
如果使用MSXML6,则需要使用AllowXsltScript属性在XSLT中手动允许脚本.((

Some added info.
If you use MSXML6 then you need to manually allow scripting in the XSLT, by using the AllowXsltScript property.. ( reference )
Depending on the way you load the xslt and its settings have a look at the examples at Script Blocks Using msxsl:script on how to alow scripts

这篇关于XSLT版本1 URL编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆