XHTML Doctype?

Discussion in 'XML' started by UKuser, Jan 20, 2009.

  1. UKuser

    UKuser Guest

    Hi Folks,

    The following code works fine in FF & IE

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="copy.xsl" ?>

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="application/xhtml+xml;" />
    <title>Simple Example </title>
    </head>

    <body style="background-color:red;">
    <p>test line of text X</p>
    </body>
    </html>

    However add the doctype
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    and serve as an xml file and it errors with the following (IE errors)

    The server did not understand the request, or the request was invalid.
    Error processing resource 'http://www.w3.org/TR/xhtm...

    The copy.xsl is:
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/1999/xhtml" version="1.0">
    <xsl:eek:utput method="xml" encoding="utf-8"/>
    <xsl:template match="/">
    <xsl:copy-of select="node()"/>
    </xsl:template>
    </xsl:stylesheet>

    Any thoughts unless I'm missing the obvious would be great. I'll keep
    investigating and see if I fix it.

    Thanks

    A
     
    UKuser, Jan 20, 2009
    #1
    1. Advertising

  2. UKuser

    Tom Wright Guest

    UKuser wrote:
    > However add the doctype
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    > and serve as an xml file and it errors with the following (IE errors)
    >
    > The server did not understand the request, or the request was invalid.
    > Error processing resource 'http://www.w3.org/TR/xhtm...
    >
    > The copy.xsl is:
    > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    > xmlns="http://www.w3.org/1999/xhtml" version="1.0">
    > <xsl:eek:utput method="xml" encoding="utf-8"/>
    > <xsl:template match="/">
    > <xsl:copy-of select="node()"/>
    > </xsl:template>
    > </xsl:stylesheet>
    >
    > Any thoughts unless I'm missing the obvious would be great. I'll keep
    > investigating and see if I fix it.


    I know when I set up an XML to HTML transform a couple of years ago, I
    couldn't get browsers to reliably interpret XHTML sent as text/xml
    correctly, so I altered it to send XHTML as text/html using the following
    output declaration:

    <xsl:eek:utput method="xml" omit-xml-declaration="yes" encoding="UTF-8"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="no"
    media-type="text/html" />

    This worked and works just fine, but browsers may have moved on and may be
    better at accepting xml now - I've not experimented again since I got it
    working.


    --
    I'm at CAMbridge, not SPAMbridge
     
    Tom Wright, Jan 20, 2009
    #2
    1. Advertising

  3. UKuser wrote:
    > Hi Folks,
    >
    > The following code works fine in FF & IE
    >
    > <?xml version="1.0" encoding="ISO-8859-1"?>
    > <?xml-stylesheet type="text/xsl" href="copy.xsl" ?>
    >
    > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    > <head>
    > <meta http-equiv="Content-Type" content="application/xhtml+xml;" />
    > <title>Simple Example </title>
    > </head>
    >
    > <body style="background-color:red;">
    > <p>test line of text X</p>
    > </body>
    > </html>
    >
    > However add the doctype
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    > and serve as an xml file and it errors with the following (IE errors)
    >
    > The server did not understand the request, or the request was invalid.
    > Error processing resource 'http://www.w3.org/TR/xhtm...
    >
    > The copy.xsl is:
    > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    > xmlns="http://www.w3.org/1999/xhtml" version="1.0">
    > <xsl:eek:utput method="xml" encoding="utf-8"/>
    > <xsl:template match="/">
    > <xsl:copy-of select="node()"/>
    > </xsl:template>
    > </xsl:stylesheet>
    >
    > Any thoughts unless I'm missing the obvious would be great. I'll keep
    > investigating and see if I fix it.
    >
    > Thanks
    >
    > A


    IE can't read that DTD (a documented non conformance of msxml, it
    doesn't allow you to default namespace attributes)
    In the xhtml+MathML DTD (eg from
    www.w3.org/math/DTD/mathml2/xhtml mathml-f.dtd
    I hand edited the xhtml bits of the combined dtd so that it would work.
    so you could use that one, or better don't specify teh dtd at all, if
    you do specfy it IE really tries to go and fetch it each time, which is
    slow, and thrashes the w3c server almost to death if everyone pings the
    dtd all the time

    David

    --
    http://dpcarlisle.blogspot.com
     
    David Carlisle, Jan 20, 2009
    #3
  4. UKuser

    Peter Flynn Guest

    David Carlisle wrote:
    [...]
    > IE can't read that DTD (a documented non conformance of msxml,


    <sigh/>
    ....and we had catalog resolution and federated mirroring of DTDs working
    over a decade ago with Panorama as a Netscape plugin...

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/
     
    Peter Flynn, Jan 22, 2009
    #4
  5. UKuser

    UKuser Guest

    On Jan 22, 8:22 pm, Peter Flynn <> wrote:
    > David Carlisle wrote:
    >
    > [...]
    >
    > > IE can't read that DTD (a documented non conformance of msxml,

    >
    > <sigh/>
    > ...and we had catalog resolution and federated mirroring of DTDs working
    > over a decade ago with Panorama as a Netscape plugin...
    >
    > ///Peter
    > --
    > XML FAQ:http://xml.silmaril.ie/


    I have managed to make this work where the DTD is hosted locally
    (served as application/xml):

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="copy.xsl" ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
    localhost/sites/dtd/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <title>Simple Example </title>
    </head>

    <body style="background-color:red;">
    <p>test line of text X</p>

    </body>
    </html>

    I needed to download the DTD and referenced docs but it seems to work
     
    UKuser, Jan 23, 2009
    #5
  6. UKuser wrote:
    > On Jan 22, 8:22 pm, Peter Flynn <> wrote:
    >> David Carlisle wrote:
    >>
    >> [...]
    >>
    >>> IE can't read that DTD (a documented non conformance of msxml,

    >> <sigh/>
    >> ...and we had catalog resolution and federated mirroring of DTDs working
    >> over a decade ago with Panorama as a Netscape plugin...
    >>
    >> ///Peter
    >> --
    >> XML FAQ:http://xml.silmaril.ie/

    >
    > I have managed to make this work where the DTD is hosted locally
    > (served as application/xml):
    >
    > <?xml version="1.0" encoding="ISO-8859-1"?>
    > <?xml-stylesheet type="text/xsl" href="copy.xsl" ?>
    >
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
    > localhost/sites/dtd/xhtml1-strict.dtd">
    >
    > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    > <head>
    > <title>Simple Example </title>
    > </head>
    >
    > <body style="background-color:red;">
    > <p>test line of text X</p>
    >
    > </body>
    > </html>
    >
    > I needed to download the DTD and referenced docs but it seems to work


    Incidentally why do you want to put the DTD on the file? The stylesheet
    will be processed by msxml in non validating mode, so the dtd will be
    read but not used for validation. Even if you cache the thing locally
    the main affect is that there is a noticable delay in rendering the file
    for no real benefit.



    --
    http://dpcarlisle.blogspot.com
     
    David Carlisle, Jan 24, 2009
    #6
  7. UKuser

    UKuser Guest

    On Jan 24, 12:39 am, David Carlisle <>
    wrote:
    > UKuser wrote:
    > > On Jan 22, 8:22 pm, Peter Flynn <> wrote:
    > >> David Carlisle wrote:

    >
    > >> [...]

    >
    > >>> IE can't read that DTD (a documented non conformance of msxml,
    > >> <sigh/>
    > >> ...and we had catalog resolution and federated mirroring of DTDs working
    > >> over a decade ago with Panorama as a Netscape plugin...

    >
    > >> ///Peter
    > >> --
    > >> XML FAQ:http://xml.silmaril.ie/

    >
    > > I have managed to make this work where the DTD is hosted locally
    > > (served as application/xml):

    >
    > > <?xml version="1.0" encoding="ISO-8859-1"?>
    > > <?xml-stylesheet type="text/xsl" href="copy.xsl" ?>

    >
    > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
    > > localhost/sites/dtd/xhtml1-strict.dtd">

    >
    > > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    > >   <head>
    > >    <title>Simple Example </title>
    > >   </head>

    >
    > >   <body style="background-color:red;">
    > >    <p>test line of text X</p>

    >
    > >   </body>
    > > </html>

    >
    > > I needed to download the DTD and referenced docs but it seems to work

    >
    > Incidentally why do you want to put the DTD on the file? The stylesheet
    > will be processed by msxml in non validating mode, so the dtd will be
    > read but not used for validation. Even if you cache the thing locally
    > the main affect is that there is a noticable delay in rendering the file
    > for no real benefit.
    >
    > --http://dpcarlisle.blogspot.com


    I'm trying to make sure the code validates - hence thinking they need
    a DTD.

    How could I make the code valid without referencing a DTD? IE doesn't
    seem
    to like it although removing the whole doctype validates it still has
    1 error.
     
    UKuser, Jan 25, 2009
    #7
  8. UKuser wrote:

    > How could I make the code valid without referencing a DTD? IE doesn't
    > seem
    > to like it although removing the whole doctype validates it still has
    > 1 error.



    most validating parsers (including the online one at w3c) can be
    configured to default a dtd for certain top level elements (eg <html> in
    this case) so you can validate the file before you serve it, putting the
    dtd on the file and causing the client to reparse the dtd isn't so
    useful, especially as you are styling with xslt so the document the
    browser is rendering isn't the document you serve but the document
    9including on IEs case the doctye) generated by xslt so it is the
    doctype specified in xsl:eek:utput, not the <!DOCTYPE in the file that
    determines whether quirks mode is used for example. (It is true that the
    xhtmml spec recommends put in a doctype on the file, but in the real
    world that has a high cost. (Unlike html where the browsers don't fetch
    the dtd, if you serve with an xml mime type then some browsers, and in
    particular IE do fetch the dtd).
    --
    http://dpcarlisle.blogspot.com
     
    David Carlisle, Jan 27, 2009
    #8
  9. UKuser

    Peter Flynn Guest

    UKuser wrote:
    [...]
    > I'm trying to make sure the code validates - hence thinking they need
    > a DTD.


    Unless you are using default values for a token list, or Notations and
    other bells and whistles, only the author needs the DTD (to make sure
    the document is constructed correctly). Once that's been done, it can be
    processed as well-formed only, without a DTD.

    > How could I make the code valid without referencing a DTD? IE doesn't
    > seem to like it although removing the whole doctype validates it
    > still has 1 error.


    I gave up trying to use XML in browsers a long time ago. The browser
    makers are not willing to support XML, so I do it all server-side.

    ///Peter
     
    Peter Flynn, Jan 29, 2009
    #9
  10. UKuser

    UKuser Guest

    On Jan 27, 1:44 am, David Carlisle <>
    wrote:
    > UKuser wrote:
    > > How could I make the code valid without referencing a DTD? IE doesn't
    > > seem
    > > to like it although removing the whole doctype validates it still has
    > > 1 error.

    >
    > most validating parsers (including the online one at w3c) can be
    > configured to default a dtd for certain top level elements (eg <html> in
    > this case) so you can validate the file before you serve it, putting the
    > dtd on the file and causing the client to reparse the dtd isn't so
    > useful, especially as you are styling with xslt so the document the
    > browser is rendering isn't the document you serve but the document
    > 9including on IEs case the doctye) generated by xslt so it is the
    > doctype specified in xsl:eek:utput, not the <!DOCTYPE in the file that
    > determines whether quirks mode is used for example. (It is true that the
    > xhtmml spec recommends put in a doctype on the file, but in the real
    > world that has a high cost. (Unlike html where the browsers don't fetch
    > the dtd, if you serve with an xml mime type then some browsers, and in
    > particular IE do fetch the dtd).
    > --http://dpcarlisle.blogspot.com


    Hi there,

    Sorry for the delay - can i just clarify something:

    a) Is there somewhere I can read more about how this all works from a
    technical level? The web generally tells you what to put not why its
    so
    b) Are you saying - put the DTD in the W3C checker but omit it from
    the final code served? As I read it - because the XSLT transforms the
    document, am I right in thinking the whole DOCTYPE line isn't
    necessary - or just the referrer to the DTD?
    i.e.
    Necessary for Validator
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
    www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    Necessary for Browsers
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"> OR Nothing?

    As a general point - has anyone done the W3 Schools XML certified
    developer exam? Any thoughts on it just for semi recognition? Does it
    cover these sorts of things?

    Thanks again

    A
     
    UKuser, Jan 31, 2009
    #10

  11. > Necessary for Validator
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
    > www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    >
    > Necessary for Browsers
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"> OR Nothing?



    what a doctype was supposed to be for is to specify the grammar (dtd)
    being used. But validating parsers (including the online w3c one)
    usually have a way to default a dtd so if you don't specify one then it
    is equivalent, to a validating parser, to using a default one (usually
    html4 transitional these days)

    Howveer browsers treat the same syntax completely differently,

    in html mode they never fetch the dtd or validate the document but they
    do recognise certain doctypes as fixed strings that turn on "standards"
    as opposed to "quirks" mode browsing. Mainly this affects css widths in
    boxes and tables, but also turns on or off any number of arbitrary
    bug-compatibility behaviours, depending on teh browser. So typically if
    you don't use a doctype the brousers try to act lie IE4 or NS4 or
    something as regards css positioning but if you specify one of a fixed
    number of magic doctypes they try harder to implement css as specified.
    google for quirks mode will give lots of info on this including pages
    where people keep up to date lists of which browsers recognise which
    doctypes.

    In xml mode the sitation is different again.

    If there is no stylesheet IE doesn't render the docuemnt at all, but ff
    safar opera will recognise xhtml and do similar doctype sniffing as for html

    If there is an xsl stylesheet the doctype desn't affect rendering (as it
    is the output from xsl that is rendered, nt the original document) FF
    will basically ignre te dtd except for a very few special ones such as
    the mathnl dtd of which it has a local copy in the firefox installation.

    IE fetches the dtd (which is why typically you don't want to do this,
    as the dtd is big and slow to download)


    David


    --
    http://dpcarlisle.blogspot.com
     
    David Carlisle, Jan 31, 2009
    #11
  12. David Carlisle wrote:

    > In xml mode the sitation is different again.
    >
    > If there is no stylesheet IE doesn't render the docuemnt at all, but ff
    > safar opera will recognise xhtml and do similar doctype sniffing as for
    > html


    Mozilla/Firefox does not do doctype sniffing when rendering
    application/xml or text/xml or application/xhtml+xml to decide whether
    to use quirks mode or standards compliant strict rendering mode. XML is
    always rendered in standards compliant strict rendering mode.

    See https://developer.mozilla.org/index.php?title=En/Mozilla's_Quirks_Mode


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jan 31, 2009
    #12
  13. UKuser

    UKuser Guest

    On Jan 31, 5:11 pm, Martin Honnen <> wrote:
    > David Carlisle wrote:
    > > In xml mode the sitation is different again.

    >
    > > If there is no stylesheet IE doesn't render the docuemnt at all, but ff
    > > safar opera will recognise xhtml and do similar doctype sniffing as for
    > > html

    >
    > Mozilla/Firefox does not do doctype sniffing when rendering
    > application/xml or text/xml or application/xhtml+xml to decide whether
    > to use quirks mode or standards compliant strict rendering mode. XML is
    > always rendered in standards compliant strict rendering mode.
    >
    > Seehttps://developer.mozilla.org/index.php?title=En/Mozilla%27s_Quirks_Mode
    >
    > --
    >
    >         Martin Honnen
    >        http://JavaScript.FAQTs.com/


    So are there any sites where I can read up more about all this?
     
    UKuser, Feb 1, 2009
    #13
  14. Martin Honnen, Feb 1, 2009
    #14
  15. Martin Honnen wrote:
    > David Carlisle wrote: [wrong]


    oops, thanks for posting the correction.

    Basic point I was trying to make that DOCTYPE means rather different
    things to a validator and a browser stil stands, but sorry I messed up
    the details.

    David

    --
    http://dpcarlisle.blogspot.com
     
    David Carlisle, Feb 2, 2009
    #15
    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. johkar

    XHTML - Doctype and output

    johkar, Oct 8, 2004, in forum: XML
    Replies:
    3
    Views:
    841
    johkar N
    Oct 9, 2004
  2. Tjerk Wolterink

    XSLT XHTML MIX DOCTYPE PROBLEM

    Tjerk Wolterink, Feb 11, 2005, in forum: XML
    Replies:
    13
    Views:
    1,150
    David Carlisle
    Feb 14, 2005
  3. Tatyana
    Replies:
    1
    Views:
    1,206
    Alan Silver
    Aug 8, 2006
  4. Rolf Welskes
    Replies:
    6
    Views:
    1,465
    Steven Cheng[MSFT]
    Aug 24, 2006
  5. Larry Lindstrom
    Replies:
    19
    Views:
    1,305
    Jonathan N. Little
    Jun 12, 2012
Loading...

Share This Page