加载样式表时出错:解析XSLT样式表失败。

时间:2017-04-06 21:37:24

标签: html xml xslt transform styling

当我尝试在Safari和Google中加载我尝试在Firefox和空白页面加载xml时收到此错误消息。我错过了错误吗? 我的造型要求:

  • 年份---粗体
  • 标题----深蓝色字体重量900
  • 导演 - 深绿色,大胆
  • 演员---男性为蓝色,女性为粉红色
  • 键入----斜体和下划线
  • 时间----深红色,粗体,下划线

XML:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="lab4_part2.xsl"?>
<streaming>
    <movies>
        <year>1985</year>
        <title>The Breakfast Club</title>
        <director>John Hughes</director>
        <actors>
            <male>Emilio Estevez</male>
            <male>Paul Gleason</male>
            <male>Anthony Micheal Hall</male>
            <male>Judd Nelson</male>
            <female>Molly Ringwald</female>
            <female>Ally Sheedy</female>
        </actors>
        <type>Comedy, Drama</type>
        <time>97</time>
    </movies>
    <movies>
        <year>1994</year>
        <title>Forrest Gump</title>
        <director>Robert Zemeckis</director>
        <actors>
            <male>Tom Hanks</male>
            <male>Mykelti Williamson</male>
            <male>Gary Sinise</male>
            <male>Haley Joel Osment</male>
            <female>Sally Field</female>
            <female>Robin Wright</female>
        </actors>
        <type>Comedy, Drama, Romance</type>
        <time>142</time>
    </movies>
</streaming>

XSLT:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/">
    <html>
      <body>
        <xsl:for-each select="streaming/movies">
          <div>
            <p><xsl:value-of select="year" style="font-weight:bold;"/></p>
            <p><xsl:value-of select="title" style="color:DarkBlue; font-
weight:900;"/></p>
            <p><xsl:value-of select="director" style="color:DarkGreen; font-
weight:bold;"/></p>
            <p>Actors</p>
            <ul>
              <xsl:for-each select="streaming/movies/actors">
                <xsl:if test="name() = 'male'">
                  <li><xsl:value-of select="male" style="color:blue;"/></li>
                </xsl:if>
                <xsl:if test="name() = 'female'">
                  <li><xsl:value-of select="male" style="color:pink;"/></li>
                </xsl:if>
              </xsl:for-each>
            </ul>
            <p><xsl:value-of select="type" style="text-decoration:underline; 
font-style:italic;"/></p>
            <p><xsl:value-of select="time" style="color:DarkRed; text-
decoration:underline; font-weight:bold;"/></p>
          </div>
        </xsl:for-each>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

1 个答案:

答案 0 :(得分:3)

您的所有var dic = ["A":23,"B":3,"C":13] for (key, value) in dic.sorted(by: { $0.0 < $1.0 }) { print("\(key)\t\(value)") } 语句似乎都有xsl:value-of个属性

style

<p> <xsl:value-of select="year" style="font-weight:bold;"/> </p> 不是style的有效属性。您应该将xsl:value-of属性移动到您正在创建的html标记上。例如

style