Re: [xsl] XSL Formatting Problem

Subject: Re: [xsl] XSL Formatting Problem
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 26 Feb 2002 10:52:14 +0000
Hi Jack,

> ************************
> The xml file follows
> ************************
>
> <?xml version = "1.0"?>
> <?xml:stylesheet type = "text/xsl" href = "dissertation.xsl"?>

That should be:

<?xml-stylesheet type = "text/xsl" href = "dissertation.xsl"?>
     ^
  hyphen, not colon

> ************************
> The xsl file follows
> ************************
>
> <?xml version = "1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/Transform/1.0";
>                 xmlns:html="http://www/w3.org/TR/REC-hrml40";
>                 result-ns="html">

That should be:

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

Namespaces are one thing that you *cannot* just guess at. Without the
correct namespace for XSLT, a stylesheet won't be recognised as a
stylesheet. If you found the namespace you're using for XSLT in a book
or online, then you should contact the publisher or author to tell
them that it's wrong.

You also need to have a version attribute on the xsl:stylesheet
element. I don't know where the result-ns attribute is coming from -
probably WD-xsl, but it doesn't exist in XSLT.

>         <!-- Sample xml style sheet
>                          Nova Southeastern University
>          -->
>
>         <xsl:template match="TitlePage">
>                 <html:title>
>                         <xsl:value-of select="DissTitle"/>
>                 </html:title>
>                 <html:body bgcolor="#efefef" font="Palatino Linotype" size="2">
>                         <xsl:value-of select="DissTitle"/>
>                 </html:body>
>         </xsl:template>

For valid XHTML, you should have a html document element and a head
element, and a p element around the text in the body. So you should
have something like:

<xsl:template match="TitlePage">
  <html:html>
    <html:head>
      <html:title>
        <xsl:value-of select="DissTitle"/>
      </html:title>
    </html:head>
    <html:body bgcolor="#efefef" font="Palatino Linotype" size="2">
      <html:p>
        <xsl:value-of select="DissTitle"/>
      </html:p>
    </html:body>
  </html:html>
</xsl:template>

But I doubt that actually makes much difference to how it's displayed.
The namespace is the most important thing.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread