XSLT questions: CSS and encoding

P

petermichaux

Hi,

I would like to know if I'm linking a CSS file in and XSLT file the
most efficient way. Below is how I'm doing it.

Also how can I make it so that the resulting XHTML file will be encoded
in ISO-8859-1? Currently the XHTML file output by this tranformation is
in charset=UTF-8.

Thanks,
Peter


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="xml"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="yes"/>

<xsl:template match="/">
<html lang="en">
<head>
<title>XSLT Catalog Template</title>
<link href='css/store.css' type='text/css'
rel='stylesheet'/>
<link href='css/catalog.css' type='text/css'
rel='stylesheet'/>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>

<xsl:template match="//category">
<h1><xsl:value-of select="name"/></h1>
<h2><xsl:value-of select="description"/></h2>
</xsl:template>

<xsl:template match="//product">
<h2><xsl:value-of select="name"/> - <xsl:value-of
select="description"/></h2>
</xsl:template>

</xsl:stylesheet>
 
J

Joris Gillis

Hi,

Tempore 07:07:41 said:
I would like to know if I'm linking a CSS file in and XSLT file the
most efficient way. Below is how I'm doing it.

The method you use is very common. I suspect most browsers would choke on other methods (processing-instructions).
Also how can I make it so that the resulting XHTML file will be encoded
in ISO-8859-1? Currently the XHTML file output by this tranformation is
in charset=UTF-8.

Just specify add an 'encoding' attribute to the 'xsl:eek:utput' element.

regards,
 
P

petermichaux

Thanks for the reply.

What are the other methods for linking a css file
(processing-instructions)? I am using server-side XSLT so maybe
processing instructions are a better way of doing it.

Thanks again,
Peter
 
J

Joris Gillis

Tempore 17:30:52 said:
Thanks for the reply.

What are the other methods for linking a css file
(processing-instructions)? I am using server-side XSLT so maybe
processing instructions are a better way of doing it.

A processing instruction such as this
<?xml-stylesheet type="text/css" href="mycss.css"?>
can be used to style up any xml document, in this case XHTML.

But, CSS stylesheets are handled on the (unreliable) client, no matter if your XSLT engine can ouput it. To avoid a fuss with MIME-types, I'd just use the standard 'link' element.

regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top