SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Barcelona
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML - XSL forcing IE into quirks mode ??

    Hi, we are building a webapp using xslt browser transformation. The problem is that the css layout was developed for standards mode in browsers yet the app seems to force IE into quirks mode messing up the layout.

    Has anyone had any experience of this problem and how to put in a doctype that doesn't force IE into quirks mode?

  2. #2
    Chessplayer kleineme's Avatar
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Do you have an XML prolog ahead of your doctype declaration? Any line ahead of the doctype will send IE6 into quirks mode, so you would have to delete it.
    Never ascribe to malice,
    that which can be explained by incompetence.
    Your code should not look unmaintainable, just be that way.

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Barcelona
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hummm I dont actually have access to the xml docs just the xsl. However I know a man who does so I'll pass the message on. Thanks.

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Can we see the XSL? It might be something really simple.

  5. #5
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Barcelona
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK this file is called base.xsl which applies to all files in the app:

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <!DOCTYPE xsl:stylesheet [
    <!ENTITY nbsp " "> <!ENTITY euro "">
    <!ENTITY ccedil ""> <!ENTITY Ccedil "">
    <!ENTITY ntilde ""> <!ENTITY Ntilde "">
    <!ENTITY aacute ""> <!ENTITY Aacute "">
    <!ENTITY eacute ""> <!ENTITY Eacute "">
    <!ENTITY iacute ""> <!ENTITY Iacute "">
    <!ENTITY oacute ""> <!ENTITY Oacute "">
    <!ENTITY uacute ""> <!ENTITY Uacute "">
    <!ENTITY copy "">
    ]>

    <xsl:stylesheet xmlnssl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xslutput encoding="iso-8859-1"/>

    <xsl:template match="base">

    <html>
    <head>
    <title><xsl:value-of select="//@title"/></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link href="/css/global.css" rel="stylesheet" type="text/css" />
    <script language="JavaScript" type="text/javascript" src="/js/global.js"></script>
    </head>

    <body onload="checkitems()">

    <div class="outer">

    <div class="topright"><a href="javascript;:"><xsl:value-of select="/page/txts/ayuda"/></a><span class="spacer">|</span><a href="javascript;:"><xsl:value-of select="/page/txts/contacto"/></a><span class="spacer">|</span><a href="javascript;:"><xsl:value-of select="/page/txts/condiciones"/></a></div>

    <div class="header"><a href="{//@uri}tplt=home"><img src="/images/shell/logo_switch.gif" id="logo" /></a></div>

    <div class="hline" id="hline-header"></div>


    <xsl:apply-templates select="/page/body"/>


    </div> <!-- outer -->


    <div class="footer">
    <div>
    <span class="copyright"><xsl:value-of select="/page/txts/copyright"/></span>
    <a href=""><xsl:value-of select="/page/txts/crew"/></a>
    <a href=""><xsl:value-of select="/page/txts/contacto"/></a>
    <a href=""><xsl:value-of select="/page/txts/condiciones"/></a>
    <a href=""><xsl:value-of select="/page/txts/ayuda"/></a>
    </div>
    </div> <!-- footer -->

    </body>
    </html>

    </xsl:template>

    </xsl:stylesheet>



    I've actually started writing a quirks mode version of the layout. But if you spot anything then great. Thanks in advance.

    PS: ignore the smilie - it should not be there!

  6. #6
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    I think here's your problem.
    HTML Code:
    <xsl: output encoding="iso-8859-1"/>
    If you want to trigger standards mode you should be specifying what type of HTML or XML you want. For example, this output tag would get your output as HTML 4.01 Strict compliant:
    HTML Code:
    <xsl:output method="html" version="4.01"
    indent="yes"
    doctype-public="-//W3C//DTD HTML 4.01//EN"
    doctype-system="http://www.w3.org/TR/html4/strict.dtd"/>

  7. #7
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Barcelona
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great it works. I didn't realise that the xsl: output tag actually sets the doctype. This is good to know for future projects since our company has started using xslt for all apps. Thanks very much.

  8. #8
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by mntoner
    Great it works. I didn't realise that the xsl: output tag actually sets the doctype. This is good to know for future projects since our company has started using xslt for all apps. Thanks very much.
    No problem, but you should know that it works differently if you want XHTML as output. Then it ends up coming out as XML, which may or may not be what you really want.

  9. #9
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Barcelona
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I understand you correctly, I can say that I do need xhtml output and I saw that the doctype was for html so I modified the tag accordingly:

    <xsl: output method="html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="iso-8859-1" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />

  10. #10
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by mntoner
    If I understand you correctly, I can say that I do need xhtml output and I saw that the doctype was for html so I modified the tag accordingly:
    Ah, but XHTML isn't HTML in the eyes of XSL processors. It's XML:
    HTML Code:
    <xsl:output method="xml" version="1.0"
    indent="yes" encoding="iso-8859-1"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
    And even that won't necessarily solve all of your problems. For example, if you wanted an external script referenced in your result document you'd end up with output like this:
    HTML Code:
    <script type="text/javascript" src="/myscript.js" />
    Output like that will make browsers choke. My best advice in this case is to output HTML 4.01 instead of XHTML and wait until XSLT 2.0, which comes with a built in XHTML output method.

  11. #11
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Barcelona
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Vinnie, that sounds like good advice. I've changed it.

    I wanted to ask you something else. I am looking for a way to view transformed HTML. Currently when you do a "view source" you only see xml. In Firefox, you can select part of the screen and right click and select "view selection source". This does give you transformed HTML but its only good for small selections and its not formatted.

    This would be useful to developers in general. Do you know of a way to do this?

  12. #12
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by mntoner
    This would be useful to developers in general. Do you know of a way to do this?
    You could try XSL Tester. I've used it in the past and it was okay. Or you could create a batch file or VBScript (or similar, depending on the platform you use) that does the transformation and writes the output to a file.

  13. #13
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Barcelona
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could try XSL Tester
    Great tool. Thanks a lot for your help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •