2013-07-10 119 views
3

我写我的XSL有问题。我有下面的代码的链接:URL编码与XSLT 1.0

<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> 

所以我需要一个变量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是'ū'逃跑的方式)有什么建议吗?谢谢。

回答

7

如果您使用的是XSLT 1.0, ,则请参阅this

对于XSLT 2.0,您可以使用它来解决问题。

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

试图用的,而不是“编码换URI”编码-URI“相同的代码,但它仍然无法正常工作两种方式:/ –

+0

使用嵌入的JScript试过吗? –

+0

不,我没有试过,你能告诉我一个例子,我怎样才能将projectNumber传递给嵌入式JScript并返回转义的projectNumber? –