使用XSLT 1.0的URL编码 [英] URL encoding with XSLT 1.0

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

问题描述

我在编写我的XSL时遇到了一个问题。我有以下代码的链接:

 < a> 
< xsl:attribute name =href>
< xsl:value-of select =concat($ myUrl,'& amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp;
< / xsl:attribute>
< xsl:attribute name =title>
< xsl:value-of select =title/>
< / xsl:attribute>
LINK
< / a>

所以我需要传递一个变量 projectNumber myUrl 的末尾。这工作很好,我在HTML中获得 ... myUrl ...& projectNumber = ... projectNumber ...



问题是,变量 projectNumber 有时会有一些字符,必须在我的href中转义链接。我尝试以许多不同的方式使用XSL函数 str:escape-uri(),但仍然没有成功...



例如,如果myUrl是 www.example.com/example.aspx?a=b ,而projectNumber是aaaūaaa
我得到href像www.example.com/example.aspx?a=b&projectNumber=aaaūaaa,但我需要得到 www.example.com/example.aspx?a=b&projectNumber=aaa%C5%ABaaa 。 (%C5%AB 是ū被转义的方式)任何建议?谢谢。

解决方案

如果您使用的是XSLT 1.0,则
然后引用这个



在XSLT 2.0的情况下,您可以使用它解决问题。

 < xsl:value-of select =concat($ myUrl,'& amp; amp; amp; amp; amp; amp; ,编码换URI($ projectNumber))/> 


I have a problem writing my XSL. I have a link with the following code:

<a>
<xsl:attribute name="href">
  <xsl:value-of select="concat($myUrl,'&amp;projectNumber=',$projectNumber)"/>
</xsl:attribute>
<xsl:attribute name="title">
  <xsl:value-of select="title"/>
</xsl:attribute>
LINK
</a>

So I need to pass a variable projectNumber to the end of myUrl. This works just fine and I get ...myUrl...&projectNumber=...projectNumber... in HTML.

The problem is, that the variable projectNumber sometimes has some characters which have to be escaped in the href of my link. I tried using the XSL function str:escape-uri() in many different ways, but still no success...

For example if myUrl is www.example.com/example.aspx?a=b and projectNumber is aaaūaaa I get href like www.example.com/example.aspx?a=b&projectNumber=aaaūaaa, but I need to get www.example.com/example.aspx?a=b&projectNumber=aaa%C5%ABaaa. (%C5%AB is the way that 'ū' is escaped) Any suggestions? Thanks.

解决方案

If you are using XSLT 1.0, then refer this.

In case of XSLT 2.0, you may use this to solve the issue.

<xsl:value-of select="concat($myUrl,'&amp;projectNumber=',encode-for-uri($projectNumber))"/>

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

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