XSLT questions: CSS and encoding

Discussion in 'XML' started by petermichaux@yahoo.com, Jul 6, 2005.

  1. Guest

    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>
     
    , Jul 6, 2005
    #1
    1. Advertising

  2. Joris Gillis Guest

    Hi,

    Tempore 07:07:41, die Wednesday 06 July 2005 AD, hinc in foro {comp.text.xml} scripsit <>:

    > 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,
    --
    Joris Gillis (http://users.telenet.be/root-jg/me.html)
    Spread the wiki (http://www.wikipedia.org)
     
    Joris Gillis, Jul 6, 2005
    #2
    1. Advertising

  3. Guest

    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
     
    , Jul 6, 2005
    #3
  4. Joris Gillis Guest

    Tempore 17:30:52, die Wednesday 06 July 2005 AD, hinc in foro {comp.text.xml} scripsit <>:

    > 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,
    --
    Joris Gillis (http://users.telenet.be/root-jg/me.html)
    Spread the wiki (http://www.wikipedia.org)
     
    Joris Gillis, Jul 6, 2005
    #4
    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. Hardy Wang

    Encoding.Default and Encoding.UTF8

    Hardy Wang, Jun 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    19,052
    Jon Skeet [C# MVP]
    Jun 9, 2004
  2. Replies:
    1
    Views:
    23,572
    Real Gagnon
    Oct 8, 2004
  3. matatu
    Replies:
    0
    Views:
    488
    matatu
    Oct 27, 2004
  4. Thomas Kellerer

    XSLT redirect:write and encoding

    Thomas Kellerer, Oct 23, 2007, in forum: Java
    Replies:
    0
    Views:
    1,522
    Thomas Kellerer
    Oct 23, 2007
  5. Replies:
    2
    Views:
    419
Loading...

Share This Page