css question

Discussion in 'XML' started by Michael Hamm, Oct 13, 2004.

  1. Michael  Hamm

    Michael Hamm Guest

    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
     
    Michael Hamm, Oct 13, 2004
    #1
    1. Advertising

  2. Michael  Hamm

    Joris Gillis Guest

    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,

    --
    Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
    Ceterum censeo XML omnibus esse utendum
     
    Joris Gillis, Oct 13, 2004
    #2
    1. Advertising

  3. Michael  Hamm

    Andy Dingley Guest

    Andy Dingley, Oct 13, 2004
    #3
  4. Michael  Hamm

    Michael Hamm Guest

    On Wed, 13 Oct 2004 22:45:41 +0100, Andy Dingley <>
    wrote, in part:
    > > There's an <em> element in there,

    >
    > 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 suggest reading this
    > http://diveintomark.org/archives/2004/02/04/incompatible-rss


    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, Oct 14, 2004
    #4
  5. Michael  Hamm

    Michael Hamm Guest

    On Wed, 13 Oct 2004 19:47:26 GMT, Joris Gillis <> wrote, in
    part:
    > 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
     
    Michael Hamm, Oct 14, 2004
    #5
  6. Michael  Hamm

    Andy Dingley Guest

    On Thu, 14 Oct 2004 13:17:11 +0000 (UTC),
    (Michael Hamm) wrote:

    >> 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.


    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.
    Using <xsl:value-of select="description" /> isn't a bad idea really -
    it's limited, but it's often the best you can achieve.

    >> I suggest reading this
    >> http://diveintomark.org/archives/2004/02/04/incompatible-rss


    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.

    --
    Smert' spamionam
     
    Andy Dingley, Oct 14, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric
    Replies:
    4
    Views:
    747
    clintonG
    Dec 24, 2004
  2. tom watson

    print.css and screen.css

    tom watson, Sep 9, 2003, in forum: HTML
    Replies:
    1
    Views:
    483
    Jukka K. Korpela
    Sep 9, 2003
  3. Replies:
    6
    Views:
    563
    Jonathan N. Little
    Mar 18, 2006
  4. AF
    Replies:
    17
    Views:
    617
    Nije Nego
    Aug 9, 2006
  5. richard
    Replies:
    12
    Views:
    772
    dorayme
    Mar 9, 2010
Loading...

Share This Page