我正在使用 XSL 在浏览器中显示电子邮件消息的 XML 表示。电子邮件附件存储在与主电子邮件 XML 文件不同的文件中,因此我希望生成的电子邮件网页包含指向其附件的链接。
然而,一些附件本身就是电子邮件,可能是转发或回复的,因此可能具有包含冒号的名称,例如FW:Important。该名称被 URL 转义为FW%3AImportant,并作为文件存储为FW%3AImportant.xml。
问题是我的 XSL 生成网页中的 URL 未转义,并且再次包含冒号 ( file://FW:Important.xml ),因此是一个损坏的链接。阻止这种行为的最佳方法是什么?
这是 XML 片段:
<email:part email:filename="FW%3AImportant">
<email:attachment filename="FW%3AImportant.xml">
FW%3AImportant.xml
</email:attachment>
</email:part>
这是 XSL 片段:
<xsl:template match="email:email/email:parts">
<xsl:for-each select="email:part/email:attachment">
<a>
<xsl:attribute name="href">
<xsl:value-of select="@filename" />
</xsl:attribute>
<xsl:value-of select="@filename" />
</a>
</xsl:for-each>
</xsl:template>