我正在尝试创建一个列出电影的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>
Run Code Online (Sandbox Code Playgroud)
但问题是某些电影标题包含空格.我可以在名字中加上空格吗?如果没有,是否有任何变通方法(除了在XML中有下划线等)?
更新:
好吧,我知道这是不可能的.目前我正在使用translate(@title, ' ', '-')哪个在CSS名称被分隔时起作用-.我仍然想知道是否有更好的方法来做到这一点.:)
class="Drag me to" 创建一个具有三个不同类的元素.
选择器.Drag.Me.To将匹配具有所有三个类的元素.
但是,它将以任何顺序匹配它们,并且不会计算重复项.
| 归档时间: |
|
| 查看次数: |
119 次 |
| 最近记录: |