Mitch

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromMitch
ToMe
SubjectOf MIME and XML parsers
Date2 May 2006 09:39
Hello,

I'm editing a website that I'm trying to make as standards-compliant as
possible. I recently had a little problem with Gecko-based browsers that
made me aware of something: some browsers ignore the doctype if the mimetype
isn't good. For example, I was told that since XHTML is in fact XML-based,
its mimetype should be application/xhtml+xml (although the W3C validator
will stilll validate it according to its doctype and not mention the
inconsistency)

As you say, such mime-type will make IE try to download the file instead of
trying to parse it (IE7 too). However using application/xml fails in IE5-7
and Firefox (reports errors in DTD).

- I wanted to know how Opera reacts: is it just sending everything throught
the same parser, ignoring the mime-type completely?
- Do you know how to add application/xhtml+xml mime-type support to IE (any
version)?
- IE5+ supports PNG transparency - on palette-based images (like GIF), I
don't think you mentioned it? OK, it's worthless anyway.

On a side note that would in part explain why Opera is smaller than Firefox:
the latter implements complete (and separate) SGML and XML parsers,
something Opera doesn't seem to have. Firefox's UI is also entirely
configurable. But then, to each his own - I've found Opera too static and
Firefox more flexible.

You can see said website at [URL] (careful,
it's in French). I'm looking to make different languages automatically
available, but I'm new at it and I'd enjoy pointers.

Thanks!

Mitch
FromMe
ToMitch
SubjectRe: Of MIME and XML parsers
Date2 May 2006 11:12
Mitch,

> As you say, such mime-type will make IE try to download the file instead
> of trying to parse it (IE7 too). However using application/xml fails in
> IE5-7 and Firefox (reports errors in DTD).

If you use a normal XHTML DTD, application/xhtml+xml should not cause
problems. As for custom ones, that is another matter.

> - I wanted to know how Opera reacts: is it just sending everything
> throught the same parser, ignoring the mime-type completely?

Opera has a HTML parser (not an SGML parser, since no browser - not
Firefox/IE/anything - has a true SGML parser), as well as an XML parser, and
it will use the XML parser for XML MIME types. The problem you seem to be
having relates to your DTD, not the content of the document itself.

Opera uses an XML parser that does _not_ validate DTDs by default (due to
the extra performance hit that would incur). However, you can enable it with
an ini setting. In Opera 9, you can set these in opera:config
opera:config#UserPrefs|XMLLoadExternalEntities
opera:config#UserPrefs|XMLValidate
(can't see what the second one does, but I mention it because it looks
relevant).

As for how the parser itself deals with different MIME types, even if I
knew, I would not be able to say :) But to me it makes sense to use a single
XML parser for all XML based languages. Using multiple parsers just means
adding a little bit of extra weight, and several more possible points of
failure, without any good reason. But I am not a browser developer, and I
would assume they know better than me.

> - Do you know how to add application/xhtml+xml mime-type support to IE
> (any version)?

Not properly, no, since IE cannot parse XHTML correctly. However, you can
force IE to attempt to use its XML or HTML parsers by setting registry keys.
Note that it will break many XHTML pages if you use the XML parser (since it
will always try to validate a custom DTD, but cannot understand many of the
parts of DTD structure), and it will use HTML error handling if you use the
HTML parser:

XML parser:

[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/xhtml+xml]
"CLSID"="{48123bc4-99d9-11d1-a6b3-00c04fd91555}"
"Extension"=".xhtm"
"Encoding"=hex:08,00,00,00

HTML parser:

[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/xhtml+xml]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Extension"=".xhtm"
"Encoding"=hex:08,00,00,00

I do not suggest using either of these unless you _really_ know what you are
doing.

> - IE5+ supports PNG transparency - on palette-based images (like GIF), I
> don't think you mentioned it? OK, it's worthless anyway.

Indeed, it is largely worthless, but you can at least use higher number of
colours than with GIF.

> On a side note that would in part explain why Opera is smaller than
> Firefox:

I will leave it up to developers to say why each is the size it is. An XML
parser is hardly likely to make that much difference though. However, in
practice, Opera is faster in my tests, and supports CSS better, and has an
extremely high level of DOM support, as well as being able to run on
extremely low memory devices (I have run it on phones with less than 8 MB
memory, where Minimo [Gecko] choked on a device with 64 - 30 free after
install of minimo). On top of that, Opera has _far_ more components than FF
has. It is more comparable with the SeaMonkey suite, with email, news, chat,
etc etc., as well as tons of features that would need many extensions (or
not be available) in Firefox, and yet it is still smaller than Firefox. Or
to put it in other words, for what it is, Firefox is far, far larger (and
has worse performance for me) than Opera.

> Firefox's UI is also entirely configurable.

Try 'tools - appearance' in Opera. You can modify menus, toolbars, mouse
gestures, keyboard shortcuts, skins, languages, etc. All with the ability to
switch between setups in your preferences. It is easily as customisable as
Firefox, if not more so:
http://my.opera.com/community/customize/

But as you say, each to their own, and whatever suits you best is what is
best for you. For me it is Opera. For you it is (or seems to be) Firefox,
and I am perfectly OK with that :)

The fact that you are not using IE is a benefit to the Web.

> I'm looking to make different languages automatically available, but I'm
> new at it and I'd enjoy pointers.

There are two easy ways to do this. Either have separate pages/sites for
each language, or use one page that can change language. Separate pages
inevitably end up with one out of date, but they are easy. Each page simply
links to other versions of the same page like this:
http://example.com/en/page.html

For single pages the right place to start is to use the Accept-Language
header. Make sure you allow for the fact that the first language listed may
not have a q value, meaning that its q value should be taken as 1. Look
through all of the languages, and select the highest q value language that
you have available. If you do not have a language of their choice available,
use the default language (probably French, in your case).

On each page, provide a list of available languages (note: do not use flags:
http://www.irt.org/articles/js173/ - use the name of the language, written
in that language; "français", "English", "Cymraeg"). The link should go
directly to the same page, with a "get" variable;
foo.php?changeLanguage=cy
That page should change the language, and set a cookie that remembers the
choice. That cookie should override the Accept-Language header (unless the
cookie specifies a language that is not available, where again, fall back to
default).

Now, store all page content in a database, or in if-elseif-else blocks on
the page, and only provide the right block, depending on what language they
choose.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromMitch
ToMe
SubjectRe: Of MIME and XML parsers
Date2 May 2006 14:20
> If you use a normal XHTML DTD, application/xhtml+xml should not cause
> problems. As for custom ones, that is another matter.

as a matter of fact, I'm linking to the W3C's one, I don't think it's
custom, is it?

<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"" xml:lang="fr" >

> to me it makes sense to use a single XML parser for all XML based
> languages.

It would be logical to throw everything through the relevant parser, yes.
It's just that I was puzzled by a Gecko 'bug' that would not recognize
xml-styled tags (such as <a id="thingy" />) and screw up some CSS rules (if
I declared some style for a , it would 'spread' onto the following elements
until its parent element was closed) even with a correct xhtml doctype and
Firefox reporting it was working in 'strict' mode - I was misled by another
bug (a real one, this time) that wouldn't highlight my 'wrong' syntax in
release builds. The xml behaviour was enabled by providing the correct
mime-type to firefox, and recent nightlies have fixed the lack of error
reporting.

>> - Do you know how to add application/xhtml+xml mime-type support to IE
>> (any version)?
>
> Not properly, no, since IE cannot parse XHTML correctly.

Even on MIME types IE blows a gasket... Geez, hadn't seen that one coming.

>> - IE5+ supports PNG transparency - on palette-based images (like GIF), I
>> don't think you mentioned it? OK, it's worthless anyway.
>
> Indeed, it is largely worthless, but you can at least use higher number of
> colours than with GIF.

I'm using the Gimp, and its highest palette setting is 256 - same as GIF, if
I'm not mistaken. However, PNG destroys the image far less when highly
compressed (since it doesn't destroy it at all).

> Or to put it in other words, for what it is, Firefox is far, far larger
> (and has worse performance for me) than Opera.

Opera is indeed very fast under Windows. I'm using 64-bit Linux though, so
it's either Gecko- or KHTML-based stuff for me if I want it to run in native
and not 'emulated' 32-bit.

>> Firefox's UI is also entirely configurable.
>
> Try 'tools - appearance' in Opera.

I've checked it. I may spend more time on it, it looks promising. The 9 beta
fixes a few display glitches and looks very nice, if I can hide the tab bar
when I only have one page open I may use it more - I'm a sucker for screen
real estate. Even in Firefox I only use extentions that hide in the Status
bar, along with small icons aligned with the main menus.

> The fact that you are not using IE is a benefit to the Web.

I do use IE - to download and install Firefox on other peoples' machines :D
Joke apart, I've been a rabid Firefox supporter since Phoenix 0.6, it's hard
to change when it's already pretty good.

> On each page, provide a list of available languages. The link should
> go directly to the same page, with a "get" variable;
> foo.php?changeLanguage=cy

I saw a part about different languages in the xhtml specs - can't the "lang"
option be used for something similar? Or is it just an accessibility help,
unused by most mainstream browsers?

Thanks for your time!

Mitch
FromMe
ToMitch
SubjectRe: Of MIME and XML parsers
Date2 May 2006 18:38
Mitch,

> as a matter of fact, I'm linking to the W3C's one, I don't think it's
> custom, is it?

Nope, that is the standard one.

> Opera is indeed very fast under Windows. I'm using 64-bit Linux though, so
> it's either Gecko- or KHTML-based stuff for me if I want it to run in native
> and not 'emulated' 32-bit.

Since 64 bit is the way things are going to go, I cannot imagine it
remaining in 32 bit only for long.

> if I can hide the tab bar when I only have one page open I may use it more

either:
tools - appearance - click on the tab bar
or:
right click on the tab bar and customize

then:
tick "Show only when needed"

>> Now, store all page content in a database, or in if-elseif-else blocks on
>> the page, and only provide the right block, depending on what language they
>> choose.
>
> I saw a part about different languages in the xhtml specs - can't the
> "lang" option be used for something similar? Or is it just an accessibility
> help, unused by most mainstream browsers?

It is not really much use on its own as it is. The main use is for speech
readers to select the correct language pronunciation, or search engines to
allow translation. It can also be used with CSS selectors, but to most
users, it serves very little purpose.

The only way you could use that is to have all language versions included on
the same page, with the relevant language tags, then have a JavaScript that
searches for all of them, and shows only the right ones. Extremely messy,
and very hard to manage, especially since things like titles and headings
wold not work very well, and it is not very accessible.


Tarquin
FromMitch
ToMe
SubjectRe: Of MIME and XML parsers
Date3 May 2006 08:18
Hello!

>> as a matter of fact, I'm linking to the W3C's one, I don't think it's
>> custom, is it?
>
> Nope, that is the standard one.

I would have been VERY surprised had it not been the case.

> Since 64 bit is the way things are going to go, I cannot imagine it
> remaining in 32 bit only for long.

Maybe in Opera 10...

> tick "Show only when needed"

I should glue my eyes open when I browse options...

> It is not really much use on its own as it is. The main use is for speech
> readers to select the correct language pronunciation, or search engines to
> allow translation. It can also be used with CSS selectors, but to most
> users, it serves very little purpose.

Bleah - meaning that on browsers without JS, all languages woudl show up.
OK, better to set it up server-side. Thanks for the help!

Mitch
FromMitch
ToMe
SubjectUpdate on CSS text shadow
Date23 June 2008 14:11
Hello,

Just a small intervention to tell you that the next version of Firefox
(currently dubbed 3.1 Shiretoko) will (and does, in nightlies) support
text-shadow (all examples shown on your page
http://www.howtocreate.co.uk/textshadow.html show up correctly).

Regards,

Mitch
FromMe
ToMitch
SubjectRe: Update on CSS text shadow
Date23 June 2008 14:56
Mitch,

> Just a small intervention to tell you that the next version of Firefox
> (currently dubbed 3.1 Shiretoko) will (and does, in nightlies) support
> text-shadow

Thanks for the note. I will update the article when I get a chance to test
for the caveats of Firefox's implementation.
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.