如何在XSLT HREF属性中显示特殊字符

发布于 2025-01-27 12:05:58 字数 3128 浏览 2 评论 0原文

我想在XSLT表中显示一个链接,该链接与Frensh特殊特征有关: 该链接由以下动态组成:https://website.com/sites/the_name_of_attachment_in_xml

XSLT链接:

<a><xsl:attribute name="href">https://website.com/sites/<xsl:value-of select="Attachments" disable-output-escaping="yes"/></xsl:attribute>
 <xsl:value-of select="Attachments" disable-output-escaping="yes"/>
</a>

html结果是:

<a href="https://website.com/sites/ExampleName.pdf">ExampleName.pdf</a>

问题是:何时引入了引入的名称extient Special optiment特殊特征。 例如:pr é sendation, 链接将是:

<a href="https://website.com/sites/Pr&amp;#233;sentation.pdf">Présentation.pdf</a>

链接中的“é”字符被“&amp; amp;#233;” i

i使用disable> disable-output-escaping = = “是的要显示正确的字符,它仅适用于 &lt; xsl:select select =“ artivements” disable-output-eScaping =“ yes”/&gt; 但是我没有在HREF属性中使用,我看到了其他解决方案,这些解决方案告诉XSLT代码更改

&lt; XSL:输出方法=“ html” /&gt; < /code> to &lt; xsl:utput:output:utput method =“ xhtml” /&gt; < /code>,但它不起作用,我会出现错误。

我想要的结果是:

<a href="https://website.com/sites/Présentation.pdf">Présentation.pdf</a>

如何使用XSLT显示使用特殊字符的校正链接?

这是XSLT代码:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" />
    <xsl:template match="/">
        <table id="tableRepeat" border="1" width="100%" style="border-collapse:collapse;color:black;font-size:100%;font-family:arial,helvetica,sans-serif;">
            <thead>
                <tr>
                    <td>Attachments</td>
                </tr>
            </thead>
            <tbody>
                <xsl:for-each select="//Items/Item">
                    <tr>
                        <td>
                        <!-- this is how i display my link  -->    
                        <a>
                        <xsl:attribute name="href">https://website.com/sites/<xsl:value-of select="Attachments" disable-output-escaping="yes"/>
                        </xsl:attribute>
                        <xsl:value-of select="Attachments" disable-output-escaping="yes"/>
                        </a>
                        <!-- end: this is how i display my link  -->
                        </td>
                    </tr>
                </xsl:for-each>
            </tbody>
        </table>
    </xsl:template>
</xsl:stylesheet>

因为我没有得到正确的URL,所以它显示了我在此

equestUrl=https://website.com/sites/training/Lists/.../pr%26

pr%26中找不到的页面,它在这里停止

,当我检查时,我得到了此信息:

i want to display a link in xslt table that contient frensh special charactres:
the link is dynamic composed from : https://website.com/sites/the_name_of_attachment_in_xml

the xslt link:

<a><xsl:attribute name="href">https://website.com/sites/<xsl:value-of select="Attachments" disable-output-escaping="yes"/></xsl:attribute>
 <xsl:value-of select="Attachments" disable-output-escaping="yes"/>
</a>

the html result is:

<a href="https://website.com/sites/ExampleName.pdf">ExampleName.pdf</a>

the issue is when the introduced name contient special charactere
for example : présentation,
the link will be:

<a href="https://website.com/sites/Pr&#233;sentation.pdf">Présentation.pdf</a>

the "é" charactere in the link is replaced by "&#233;"

i used disable-output-escaping="yes to display correct charactere it worked just for
<xsl:value-of select="Attachments" disable-output-escaping="yes"/>
but didn't work in href attribute, i see other solution that tell to change in xslt code the

<xsl:output method="html" /> to <xsl:output method="xhtml" /> , but it didn't work form me i get error.

the result i want is:

<a href="https://website.com/sites/Présentation.pdf">Présentation.pdf</a>

How can i display the correcte link with special charactere using xslt?

this is xslt code:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" />
    <xsl:template match="/">
        <table id="tableRepeat" border="1" width="100%" style="border-collapse:collapse;color:black;font-size:100%;font-family:arial,helvetica,sans-serif;">
            <thead>
                <tr>
                    <td>Attachments</td>
                </tr>
            </thead>
            <tbody>
                <xsl:for-each select="//Items/Item">
                    <tr>
                        <td>
                        <!-- this is how i display my link  -->    
                        <a>
                        <xsl:attribute name="href">https://website.com/sites/<xsl:value-of select="Attachments" disable-output-escaping="yes"/>
                        </xsl:attribute>
                        <xsl:value-of select="Attachments" disable-output-escaping="yes"/>
                        </a>
                        <!-- end: this is how i display my link  -->
                        </td>
                    </tr>
                </xsl:for-each>
            </tbody>
        </table>
    </xsl:template>
</xsl:stylesheet>

because i didn't get the right url, it shows me page not found with this

equestUrl=https://website.com/sites/training/Lists/.../pr%26

pr%26 it stop here

and when i inspecte i got this:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文