名称中的CSS空间和麻烦的XSLT

问题描述

| 我正在尝试创建一个列出电影的XSLT,并设置标题的样式,以便每个标题都有其自己的颜色,然后选择带有插值的标题(XPath?) 这是XSL文件:
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">
<xsl:template match=\"/\">
    <html>
        <head>
            <title>Videos</title>
            <style>
                table,tr,td { border: thin black solid }
                th { background-color: #AAFFAA }
                .Daredevil { color: red; }

                /* Look at those spaces! Hrmphf! */
                .Drag Me To Hell { color: green; }
            </style>
        </head>
        <body>
            <table>
                <tr><th>Movies</th></tr>
                <xsl:apply-templates select=\"//movie\"/>
            </table>
        </body>
    </html>
</xsl:template>
<xsl:template match=\"//movie[not(@title=preceding::movie/@title)]\">

    <!-- Title should be the one of the titles in the CSS -->
    <tr class=\"{@title}\"><td><xsl:value-of select=\"@title\"/></td></tr>

</xsl:template>
</xsl:stylesheet>
但是,问题在于某些电影标题包含空格。名称中可以有空格吗?如果没有,是否有任何变通办法(除了在XML中带有下划线或类似符号)? 更新: 好的,我知道这是不可能的。目前,我使用的是
translate(@title,\' \',\'-\')
,当CSS名称由ѭ2分隔时,该功能就可以使用。我仍然想知道是否有更好的方法可以做到这一点。 :)     

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)