css question

Michael Hamm

Usenet Archive
Joined
Jul 24, 2000
Messages
11
Reaction score
0
I'd appreciate any help anyone could provide in this matter.

Please see http://math.wustl.edu/~msh210/rss.xml . There's an <em> element in there, which should, by my reckoning, show up italicized in my Web browser (IE6), but doesn't. I assume that I did something wrong (although problems with IE are, in general, not unheard-of); can someone please tell me what it is I did wrong?

Some more info (which you can figure out yourself by reading the documents): rss.xml calls http://math.wustl.edu/~msh210/rss.xsl which, in turn, has a <link rel="stylesheet"/> element (which my UA uses) and a <style> element (which my UA does not seem to use: it's the <style> element that says <em>s should be italicized).

As I say, I'd appreciate any help.

Michael Hamm
AM, Math, Wash. U. St. Louis
Standard disclaimers:
http://math.wustl.edu/~msh210/ ... legal.html
 

Joris Gillis

Usenet Archive
Joined
Sep 28, 2004
Messages
355
Reaction score
0
Hi,

The problem here is the '<xsl:value-of select="description" />': it returns the concatenation of all text descendants of the 'description node'. All other nodes like 'em' are ignored. You could use '<xsl:copy-of select="description" />' to copy all nodes including 'em'. (or you could use '<xsl:apply-templates/>')

Also note that you're not generating html.
You don't specify the output type and the generated document itself is not valid (X)html. In this case the behaviour of a browser is not defined, so it is not unlikely to see css rules not being applied.

the stylesheet looks like this

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:eek:utput method="html"/>

<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" href="basic.css" type="text/css" /> <style type="text/css"> em{font-style:italic} em em{font-style:normal} em em em{font-style:italic} strong{font-weight:bolder} </style> </head> <body> <xsl:apply-templates select="//rss/channel"/> </body></html> </xsl:template>

<xsl:template match="channel">

<title><xsl:value-of select="title" /></title>
<h1><xsl:value-of select="title" /></h1>
<p><xsl:value-of select="description" /></p>
<xsl:for-each select="item">
<div>
<h2><xsl:value-of select="title" /></h2>
<address><xsl:value-of select="pubDate" /></address>
<p><xsl:copy-of select="description"/></p>
</div>
</xsl:for-each>
<address><a><xsl:attribute name="href"><xsl:value-of select="link" /> </xsl:attribute><xsl:value-of select="copyright" /></a></address> </xsl:template></xsl:stylesheet>

regards,
 

Michael Hamm

Usenet Archive
Joined
Jul 24, 2000
Messages
11
Reaction score
0
There is indeed. There isn't an <em> in RSS.

I didn't refer to any DTD, so there's an anything-I-want in RSS. As long as I tell the UA what to do (which I thought I did, using CSS), that should suffice, no?

I read it (not very carefully. That is, I read through all the text, but not all the examples, and none of the external citations). I fail to see its relevance.

Michael Hamm
AM, Math, Wash. U. St. Louis
Standard disclaimers:
http://math.wustl.edu/~msh210/ ... legal.html
 

Michael Hamm

Usenet Archive
Joined
Jul 24, 2000
Messages
11
Reaction score
0
The problem here is the '<xsl:value-of select="description" />': it returns the concatenation of all text descendants of the 'description node'. All other nodes like 'em' are ignored. You could use '<xsl:copy-of select="description" />' to copy all nodes including 'em'.

Thanks very much; I've fixed it per your suggestion (this first one that I quoted), and all seems well.
Also note that you're not generating html.
You don't specify the output type and the generated document itself is not valid (X)html. In this case the behaviour of a browser is not defined, so it is not unlikely to see css rules not being applied.

Every browser under the sun knows what to do with a page that looks like <title>foo</title><h1>bar</h1><p>baz</p> which is what I generate. The only problem, I guess, is that I don't specify a MIME type for the generated page. (Browsers faced with <title>foo</title><h1>bar</h1><p>baz</p> in a page served with MIME type text/plain will generally not display it as an HTML page.) So perhaps I'd better, as you suggest, use
<xsl:eek:utput method="html"/>

Thanks again for your help.

Michael Hamm
AM, Math, Wash. U. St. Louis
Standard disclaimers:
http://math.wustl.edu/~msh210/ ... legal.html
 

Andy Dingley

Usenet Archive
Joined
Feb 23, 2000
Messages
3,303
Reaction score
0
I didn't refer to any DTD, so there's an anything-I-want in RSS.

No there isn't. There might be, but then it stops being valid RSS.
As long
as I tell the UA what to do (which I thought I did, using CSS), that should suffice, no?

As Joris has already said, then the "simple" problem was evaluating <description> as text, not as a node-set.

As a general rule, it's (sadly) not practical to process RSS with pure XSLT - or at least not to process embedded HTML markup in RSS with it.

RSS is riven with problems, version incompatibilities and contradictory specifications. Mny of these are centred on how to represent embedded HTML markup. The reference is one of the clearest summaries of this sorry mess.

You can't generate RSS by blindly embedding chunks of literal HTML into it, as your example did. If you try it, your code will barf when it receives &eacute; or <br> (and a few others). If you're generating it yourself, then you might be able to limit the content to a balanced XML fragment (as your example was) which is rather more workable. This might even work for you, but don't fool yourself that it's valid RSS, or that other consumers will be happy to accept it.
 

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
548,042
Messages
3,104,224
Members
248,132
Latest member
henrywalsh

Latest Threads

Top