Error loading stylesheet: failed to parse XSLT stylesheet

This is my xml file:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="hello.xsl"?>
<message>
    <greeting>Hello World!</greeting>
</message>

And this is my xsl file:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/Transform">
<xsl:template match="/">
<html>
<body>
<h1><xsl:value-of select="message/greeting"/></h1>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

When I run the xml file in firefox, it gives "Error loading stylesheets: XSLT stylesheet parsing failed." error. I am new to xml, please someone tell me what the error is. And can you tell me a way to find the error. Thank!

+5
source share
4 answers

You specified the wrong namespace for XSL:

xmlns:xsl="http://www.w3.org/1999/xsl/Transform"

Instead, you should use:

xmlns: xsl = "http://www.w3.org/1999/ XSL / Transform"

Remember that XML is case sensitive .

+6

http://www.w3.org/1999/ XSL/Transform

+4

For me, the xsl stylesheet version version 1.0 to 1.1 worked.

<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/xsl/Transform">
+3
source

I had the same problem as you. Finally, I found my solution.

The solution is to open the xsl file with your browser (in my case firefox) and an error may occur and fix the error.

In my cases, there is no / slashes in the body tag.

0
source

All Articles