RE: [xsl] XSL Formatting Problem

Subject: RE: [xsl] XSL Formatting Problem
From: "Jack Cane" <jwcane@xxxxxxxxxxx>
Date: Tue, 26 Feb 2002 07:58:49 -0500
Bless you, Jeni, it worked! Now, two more questions:

Would like to center some text. Neither of the following works:

	<html:p align="center">
	  <xsl:value-of select="DissTitle"/>
	</html:p>

	<html:p><html:center>
	  <xsl:value-of select="DissTitle"/>
	</html:center></html:p>

The lines,

	<html:title>
	  <xsl:value-of select="DissTitle"/>
	</html:title>

were intended to act as the conventional title tag, which should place the
content in the browser's title bar. Instead, the content is rendered on the
browser content window, and the title bar reflects the path and file name on
the local machine.

-----Original Message-----
From: Jeni Tennison [mailto:jeni@xxxxxxxxxxxxxxxx]
Sent: Tuesday, February 26, 2002 5:52 AM
To: Jack Cane
Cc: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] XSL Formatting Problem


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