Xml – Why won’t Firefox parse this XSLT

firefoxxmlxslt

I've recently been playing around with XML formatting and XLST files, because it seems like the most direct solution to a UI problem I've been wrestling with involving users accessing the central data differently. In my experimentation I've created a really nice formatting sheet that looks great… in Internet Explorer. When I test it in Firefox, I consistently get the same error message:

"Error loading stylesheet: Parsing an XSLT stylesheet failed."

I've tried paring the stylesheet down to a very basic document and still experience the same problem. I've been checking tutorials and other webforums and mimic'ing examples, but I can't seem to find anything that is explicitly applicable.

Here's my test XML file:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="fox.xslt"?>
<article>
   <title>Making Excellent Pasta Sauce</title>
   <synopsis>A simple recipe for an amazing sauce, with tips on getting that extra flavor.</synopsis>
   <content>Here is my content.</content>
   <tags>
      <tag>sauce</tag>
      <tag>recipes</tag>
   </tags>
</article>

And then, here's my XSLT file (named, as you might tell from the example block above, "fox.xslt".

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
   <head>
   </head>
   <body>
   <xsl:for-each select="article">
      TITLE: <xsl:value-of select="title"/> <BR/>
      SYNOPSIS: <xsl:value-of select="synopsis"/> <BR/><BR/>
   </xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

I suspect that it may have something to do with
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
because I've seen a few different things done with this in examples, I've tried a few of the different values here and haven't seem to hit on one that works with this example.

I'm sure it's probably a basic problem, I just have been flummoxed at tracking down. Hopefully someone can lead me to the "forehead smacking moment".

Thanks in advance!

Best Answer

Try to replace your stylesheet element with this:

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

You may also want to add this:

xmlns="http://www.w3.org/1999/xhtml"