2
votes

I get this error message when I try to load my xml in Firefox and a blank page when I try to load in Safari and Google. Is there an error I am missing? My styling requirements:

  • Year---bold
  • Title---- dark blue font weight of 900
  • Director—dark green, bold
  • Actors --- blue if male, pink if female
  • Type---- italic and underline
  • Time---- dark red, bold, underline

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
You've been told what the errors are, but the root cause of your problem is that you're running this stylesheet and not seeing the error messages. Generally, running XSLT in the browser isn't the best development environment, but most of the browsers do give diagnostics in the developer console and you need to become familiar with how to find them.Michael Kay
I've also recommend xsltransform.net as a tool for testing your XSLT, but unfortunately the service is not available at the moment...Tim C
@TimC I really think you should post a canonical answer. That service is back up now.wizzwizz4

1 Answers

3
votes

All of your xsl:value-of statements seem to have style attributes on them

<p>
   <xsl:value-of select="year" style="font-weight:bold;"/>
</p>

style is not a valid attribute on xsl:value-of. You should move the style attribute onto the html tags you are creating in all cases. For example

<p style="font-weight:bold;">
   <xsl:value-of select="year" />
</p>