I think I'm declaring my (XSLT) stylsheet incorrectly.

wxdqz

New Member
Hi, folks. I've been using a stylesheet I had written for changing xhtml to html for quite some time now without any problems. I've been passing XHTML files and my stylesheet to my libxslt install (via PHP5) for ages now without any problems.

I thought I'd rewrite my PHP a bit to allow for client side processing if the client declared that it was capable of doing so. I thought I'd best start at the bottom with the basics, just to be certain of what exactly my PHP should output to the browser. So I thought I'd test out changing a standard markup file I have been using for ages, with a stylesheet I've been using for ages. The result wasn't exactly what I was expecting.

The markup is:


<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet title="transform-to-html" type="application/xml" href=http://www.webdeveloper.com/forum/archive/index.php/"/xml/xhtml_to_html.xml"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Standard markup for inclusion into the document.</title>
<meta name="MSSmartTagsPreventParsing" content="TRUE"/>
<meta http-equiv="Content-type" content="application/xhtml+xml; UTF-8"/>
<meta name="Content-Script-Type" content="text/javascript"/>
<meta name="Content-Style-Type" content="text/css"/>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"/>
</head>
<body>
<div id="container">
<div id="page_head">
<h1>Stephen Philbin</h1>
</div>
<div id="content">
</div>
</div>
</body>
</html>


The Processing instruction is new in today, but the rest of the markup has ben in use for a long time.

Here's the stylesheet I've been using:


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:html="http://www.w3.org/1999/xhtml" xsl:version="1.0" xsl:exclude-result-prefixes="html">
<xsl:output method="html" version="4.0" encoding="UTF-8" omit-xml-declaration="yes" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system="http://www.w3c.org/TR/html4/strict.dtd" indent="yes" media-type="text/html"/>

<xsl:template match="/html:html">
<html>
<xsl:apply-templates select="@*|node()"/>
</html>
</xsl:template>

<xsl:template match="html:*">
<xsl:element name="{local-name(.)}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>

<xsl:template match="@*|text()|comment()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="@xml:lang">
<xsl:attribute name="lang">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>

</xsl:stylesheet>


I've been making the transformation on the server side without a hitch for ages, but when I add the PI in the XML file for the client to perform the transformation, Firefox just says Error loading stylesheet: Parsing an XSLT stylesheet failed.. It doesn't even give a reason why. They seem to come out fine in Opera and Konqueror, but I don't know if Firefox is geting something wrong or I'm getting something wrong and Firefox is stating it in it's traditional "Yellow screen of death" fasion whilst Opera and Konqueror are just ignoring the error.

Any guidance would be appreciated.
 
Back
Top