gpt4 book ai didi

xslt - 使用 XSLT 1.0 进行 URL 编码

转载 作者:行者123 更新时间:2023-12-04 14:02:02 25 4
gpt4 key购买 nike

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

<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 .这工作得很好,我得到 ...myUrl...&projectNumber=...projectNumber...在 HTML 中。

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

例如,如果 myUrl 是 www.example.com/example.aspx?a=b项目编号为 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,
然后引用 this .

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

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

关于xslt - 使用 XSLT 1.0 进行 URL 编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17569955/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com