【发布时间】:2016-04-06 21:07:31
【问题描述】:
我正在尝试从一个 xml 文件中获取,该文件包含一些电影的数据,本周正在播放的所有电影,但它会将所有电影打印出来。我是新来的 xml 和 xslt 所以,任何帮助将不胜感激!我的 xml 看起来像:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="movies.xsl"?>
<?xml-stylesheet type="text/css" href="movies.css"?>
<movies>
<movie>
<title> Title1 </title>
<actor> Actor1 </actor>
<genre> Genre1 </genre>
<dateOfPlaying>20160403</dateOfPlaying>
<duration> Duration1 </duration>
</movie>
<movie>
<title> Title2 </title>
<actor> Actor2 </actor>
<genre> Genre2 </genre>
<dateOfPlaying>20160420</dateOfPlaying>
<duration> Duration2 </duration>
</movie>
<movie>
<title> Title2 </title>
<actor> Actor2 </actor>
<genre> Genre2 </genre>
<dateOfPlaying>20160406</dateOfPlaying>
<duration>Duration3</duration>
</movie>
</movies>
和 xsl 文件:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<body>
<h2> Movies report </h2>
<table>
<xsl:for-each select="movies/movie">
<xsl:if test="number(dateOfPlaying) > 20160401 and number(dateOfPlaying) < 20160408">
<tr>
<td>
<xsl:value-of select="title"/>
</td>
<td>
<xsl:value-of select="actor"/>
</td>
<td>
<xsl:value-of select="genre"/>
</td>
<td>
<xsl:value-of select="dateOfPlaying"/>
</td>
<td>
<xsl:value-of select="duration"/>
</td>
<tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
【问题讨论】:
标签: xml date xslt comparison