...

View Full Version : Strange Mozilla behaviour?



mpjbrennan
01-17-2003, 10:30 PM
I have a few XML demo pages on my site. All of them have been checked out using both IE6 and Mozilla 1.0 and they perform as expected when accessed from the C: drive. When I upload them to my site however Mozilla does not want to play. I click on a link and get the status message "Document:done", but the display does not change. However if I then click on "View Source" I get the coding for the page I am trying to access. I just don't understand it. Can anyone shed any light on this?

Here is a link to one of the pages:

http://www.patrick-brennan.com/xml/photo_album.xml

Patrick

jkd
01-17-2003, 11:34 PM
Shouldn't XSL be served as text/xml, not text/xsl (I don't believe that is a correct mime-type)?

mpjbrennan
01-18-2003, 09:02 AM
Jason,

Where are you picking up the mime type text/xsl?

patrick

cg9com
01-18-2003, 10:49 AM
second line
<?xml-stylesheet type="text/xsl" href="photo_album.xsl"?>

mpjbrennan
01-18-2003, 02:05 PM
OK - I wasn't sure what Jason was referring to. The line you quote is the format recommended in all the XSL references I have read. It's also the format used in the W3Schools web tutorials - for example check out the following link (which incidentally transforms nicely in Mozilla!)

http://www.w3schools.com/xsl/cdcatalog_with_xsl.xml

Your comments led me to experiment however and what I discovered was that if I rename my xsl stylesheet and give it a .xml suffix then it works fine. It may be that my ISP server doesn't properly serve up the .xsl mime-type - though why that doesn't also affect Internet Explorer is a mystery to me.

update: I copied the w3schools xml and xsl files to my site and got exactly the same behaviour - transformation with IE but not Mozilla, even though Mozilla does successfully transform these same files when I access them directly from w3schools.com. The problem must therefore be due to the way my site server is dishing up the files.

patrick

brothercake
01-18-2003, 03:51 PM
Personally, I've had very little succes in client-side transformation in mozilla; perhaps for the same reasons as you (whatever they are - sorry I don't know) ... I never really investigated because IMHO client-side transformation is a non-starter for practical applications; I'd do it server-side.

jkd
01-18-2003, 04:57 PM
I got the text/xsl mime-type from trying to view your XSLT document on your server. It asks me to download it (claiming the mime-type is text/xsl.)

As unbelievable as this sounds, but w3schools is often trash when it comes to XML and such. There is no such mime-type as text/xsl. It is simply IE being stupid, once again. (Kind of like older versions of MSXML not supporting the correct XSLT namespace)

However, Mozilla does let you do type="text/xsl" in the processing instruction tag, because I believe IE requires it (it is so stupid!!).

However, the document MUST be served as text/xml, as per the XSLT 1.0 specification. Mozilla has strict enforcement of mime-types. Unlike IE, it doesn't do mime-type second-guessing or even overriding based on the extension, as file extensions are meaningless on the web.


I've never had any problems with client-side XSLT transformation in Mozilla when I'm doing everything correctly.

mpjbrennan
01-18-2003, 08:49 PM
Jason,

It isn't just w3schools that use the link

<?xml-stylesheet type="text/xsl" href=some_file.xsl"?>

- Michael Kay also uses it in his book "XSLT" 2nd edition. Most people regard this as a fairly definitive work.

Older versions of IE supported the working draft namespace for xsl because there wasn't anything else at the time - I don't think that was being stupid, I think it was being helpful, giving users a tool to experiment with. Present versions of IE use the correct namespace.

I found your comments regarding mime-types very interesting and from a brief read of the subject at IANA I see that you are right that text/xsl is not a recognised type. I shall look into this further.

patrick

jkd
01-18-2003, 09:43 PM
Originally posted by mpjbrennan
Jason,

It isn't just w3schools that use the link

<?xml-stylesheet type="text/xsl" href=some_file.xsl"?>

- Michael Kay also uses it in his book "XSLT" 2nd edition. Most people regard this as a fairly definitive work.

Well it is technically incorrect. I think it is common practice because IE requires it (? I don't actually remember if it transform with type="text/xml" or not...), and Mozilla is smart enough to use the real mime-type of the file.

jkd
01-18-2003, 09:45 PM
Originally posted by mpjbrennan
Older versions of IE supported the working draft namespace for xsl because there wasn't anything else at the time - I don't think that was being stupid, I think it was being helpful, giving users a tool to experiment with. Present versions of IE use the correct namespace.

Yes, that was very nice. However after XSLT was standardized, it didn't support the correct namespace for some time. That was what bugged me.

mpjbrennan
01-19-2003, 01:26 AM
Jason,

Can you help me with one more aspect. I have changed all my xsl stylesheets to .xml and they now render satisfactorily in both IE and Mozilla. As I am in the process of migrating from Windows to Linux this is v. important for me. However, I find that in Mozilla all my pages are surrounded with a white margin. How can I get rid of this? I have looked through the CSS spec but cannot find any answer. The following page gives an example:

http://www.patrick-brennan.com/xml/photo_album.xml


thnx in anticipation

patrick

jkd
01-19-2003, 02:49 AM
Err, that's pretty odd. Perhaps:

*:root {
margin: 0;
}

Will fix it? I'm assuming the margin is being generated by the <html> element.... (you could use "html { }" as the selector in that case).

brothercake
01-19-2003, 03:28 AM
I don't wanna stray off topic too much ... or rant too much ... but doesn't all this cross-browser XML parsing idiosynchrasies stuff just turn you off completely? I don't dispute for a second that mozilla is correct over IE, but it's not that - it's that XML is supposed to free us from tedious environment specific logic. Why have any truck with anything that makes that harder?

Personally, I have no time for client-side transformation at all; or is there something amazingly useful which can't be done any other way but client-side, and I'm just failing to see it?

jkd
01-19-2003, 03:49 AM
Originally posted by brothercake
Why have any truck with anything that makes that harder?

You're not. This is why IE is continuing to stunt and retard the future of the web.

The only advantage I've come across with client-side transformations is that you don't need a server with sablotron or something equivalent installed, which is an issue for some people. It also takes some load off the server, especially if you're transforming relatively large documents.

mpjbrennan
01-19-2003, 10:52 AM
Thanks Jason - I hadn't thought of assigning the background attribute to the html element but it did the trick.

I think it's a little extreme to say that IE is stunting and retarding the future of the web. Standards are important, but only if they are good standards. Personally I think the XSLT standard is flawed in one major aspect - it relies upon a processing instruction to be embedded in the XML document which is being transformed. This defeats the central objective of having pure data in an XML document. IMHO an XSL stylesheet should import the XML document it is to transform. The it would truly be possible for an XML document to be transformed by several different stylesheets.

End of rant - once again thanks for the assistance.

patrick

brothercake
01-19-2003, 05:39 PM
Originally posted by mpjbrennan
I think the XSLT standard is flawed in one major aspect - it relies upon a processing instruction to be embedded in the XML document which is being transformed


I'd agree if that were the only way ... but there's lots of ways to link an XML doc and XSL stylesheet together - javascript, php, asp ...

And I believe (I read this superficially but haven't tried it yet) there's an XPointer method for symbolically linking two XML documents together, which can be used in a way such that a stylesheet effectively imports an XML doc to process, so the link reference is inside the stylesheet instead of the XML.

jkd
01-19-2003, 06:48 PM
Originally posted by brothercake
And I believe (I read this superficially but haven't tried it yet) there's an XPointer method for symbolically linking two XML documents together, which can be used in a way such that a stylesheet effectively imports an XML doc to process, so the link reference is inside the stylesheet instead of the XML.

You can use the document() XSLT XPath function to load a remote XML document, and then execute XPath matches against it. You can use that as a slight hack by dynamically generating essentially an empty XML document with a processing instruction pointing to the "stand-alone" XSLT document.

I've done something similar before, but not quite that.

mpjbrennan
01-19-2003, 08:20 PM
Yes, but wouldn't it be so much better if you could simply write something like:

<?xml-doc href="some_file.xml"?>

in your stylesheet

patrick

jkd
01-19-2003, 08:22 PM
Originally posted by mpjbrennan
Yes, but wouldn't it be so much better if you could simply write something like:

<?xml-doc href="some_file.xml"?>

in your stylesheet

patrick

Yes, I agree fully.... perhaps you might want to suggest this to the XSLT mailing list at w3.org?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum