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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top