I''m playing with XML using Builder but seem to be having some trouble in Explorer 6. My sample code: xml = Builder::XmlMarkup.new xml.instruct! xml.instruct! ''xml-stylesheet'', :href=>''/stylesheets/style-xml.css'', :type=>''text/css'' xml.declare! ''DOCTYPE'', :html, :PUBLIC, "-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" xml.html ( :xmlns=>"http://www.w3.org/1999/xhtml", :lang=>"en-US", ''xml:lang''=>"en-US" ) { xml.head { xml.title ''My test page'' } xml.body { xml.comment ''Test comment'' xml.br xml.p xml.em ''TEST!'' }} This displays as expected under FireFox. But under Explorer 6 the line breaks don''t display and the title shows up as regular text. I copied the document headers from an old Perl/CGI app that works fine under Explorer. The stylesheet *is* read and contains definitions for body, comment and em only. Can anyone point out where I''ve gone wrong? Kirk -- Posted via http://www.ruby-forum.com/.
On Tuesday 27 Dec 2005 22:01, Kirk Bocek wrote:> I''m playing with XML using Builder but seem to be having some trouble in > Explorer 6. My sample code: > [SNIP] > This displays as expected under FireFox. But under Explorer 6 the line > breaks don''t display and the title shows up as regular text. I copied > the document headers from an old Perl/CGI app that works fine under > Explorer. The stylesheet *is* read and contains definitions for body, > comment and em only.I would guess it''s down to IE only supporting XHTML when it''s served as text/html, and that by using a .rxml template, you''ll be serving it as application/xml. See this: http://en.wikipedia.org/wiki/Criticisms_of_Internet_Explorer#XHTML For XHTML documents in Rails, you can (or most probably "should") use regular .rhtml files, which are then served as text/html - this works fine for me using XHTML 1.0 Strict. Or I guess you could use .rxml templates and munge the headers in your controller, using: headers[''Content-Type''] = "text/html" I haven''t actually tried that myself, although did experiment sending some other .rxml stuff I was generating as text/plain in order to read it straight in the browser, which worked, so I can think of no reason why the above suggestion wouldn''t. None of these are particularly ideal solutions - the best one would be to eliminate Internet Explorer from existence, or at least until such time as it becomes a real browser and keeps well up-to-date with the fast-moving standards! ;-) For XHTML 1.0 both transitional and strict, the specs allow you to serve it as text/html, even though application/xhtml+xml would be more correct. That is only mandatory with XHTML 1.1, which is why IE can''t handle XHTML 1.1 when served properly. This may not be your exact problem, but I''m sure it''s a contributing factor. In the very least, you shouldn''t be serving XHTML as just application/xml, because that''s a bit on the vague side. IE can handle XML a bit (AFAIK, but I rarely use IE these days), but I don''t know what it would do if you sent it XHTML as application/xml - my guess is it would choke rather horribly, in some way similar to what you are seeing at the moment. ;-) Hope this helps! ~Dave -- Dave Silvester Rent-A-Monkey Website Development Web: http://www.rentamonkey.com/
Thanks for the reply, Dave. Dave Silvester wrote:> I would guess it''s down to IE only supporting XHTML when it''s served as > text/html, and that by using a .rxml template, you''ll be serving it as > application/xml. > > See this: > > http://en.wikipedia.org/wiki/Criticisms_of_Internet_Explorer#XHTMLExcellent link! I knew Explorer would have problems. This is a nice summary of all of them.> For XHTML documents in Rails, you can (or most probably "should") use > regular .rhtml files, which are then served as text/html - this works > fine for me using XHTML 1.0 Strict.Yep. Works for me too. I''m playing with .rxml because it was suggested as a preferred way to progmatically generate web pages as opposed to using <% %>. I''ve done it forever using Perl''s CGI module. Trying to figure out how to do it in Rails.> Or I guess you could use .rxml templates and munge the headers in your > controller, using: > > headers[''Content-Type''] = "text/html"Well, this does seem to cause *both* browsers to act differently. Both seem to ignore <?xml-stylesheet ...> They seem to read <LINK ...> but do strange things. Maybe only embedded styles will work?> None of these are particularly ideal solutions - the best one would be > to > eliminate Internet Explorer from existenceSure, but if we''re writing an app for public consumption...> IE can handle XML a bitYep, it was partially working before I made your Content-Type change. If I can figure out how to set the page title and get paragraph breaks, it would work fine. Thanks for the suggestion, though, it''s gotten me one step further along. Kirk -- Posted via http://www.ruby-forum.com/.
Dave Silvester wrote:> by using a .rxml template, you''ll be serving it as > application/xml.Oh, and it actually it comes over as ''text/xml'' Kirk -- Posted via http://www.ruby-forum.com/.
On Wednesday 28 Dec 2005 19:31, Kirk Bocek wrote:> Well, this does seem to cause *both* browsers to act differently. Both > seem to ignore <?xml-stylesheet ...> They seem to read <LINK ...> but do > strange things. Maybe only embedded styles will work?Yes, I believe so - it''s IE that''s the problem. The trouble is, what works for Firefox and other modern browsers will not work for IE. So essentially, you need to use content negotiation to give the browser what it prefers. I''ve done this in PHP a few times (actually, my main www.rentamonkey.com site does it) to serve XHTML 1.1 to browsers that will accept it properly, but change it to XHTML 1.0 as text/html for those that won''t. I''m not sure it''s an ideal solution, or even worth it, but I wanted to try it out somewhere so that was as good a place as any to do it. I haven''t figured out content negotiation in Rails yet (not that I''ve tried), but for now am happy enough with XHTML 1.0 Strict served as text/html. Whatever, you''re not going to be able to get this to work in IE using xml-stylesheet directives, AFAIK, because IE sucks at this kind of stuff.> Sure, but if we''re writing an app for public consumption...I know, it was a joke... didn''t you see the smiley? ;-) ;-) In web developer utopia, there would be no Internet Expletive!> Yep, it was partially working before I made your Content-Type change. If > I can figure out how to set the page title and get paragraph breaks, it > would work fine.No idea, but I guess you need to check out how IE handles pure XML stuff, rather than application/xhtml+xml, although then I guess you''d still need content negotiation, or you could send it all as text/xml (saw your other email, my bad, I didn''t check it before, just assumed .rxml sent as application/xml) but that might have weird results. Ultimately, I think you can do what you want to do by sending it as text/html, and using regular XHTML embedded stylesheet stuff rather than xml-stylesheet directives. Or figure out content negotiation in Rails, then set the page up as appropriate. Incidentally, if you''d like to see how I did it in PHP, check here: http://www.rafb.net/paste/results/cyGrz844.html That''s the code from www.rentamonkey.com. I reckon it would actually be quite easy (and undoubtedly neater - PHP kinda grosses me out these days!) to convert that to Rails, so feel free to if you like *ALTHOUGH* I''m still not sure there''s actually any point in doing that, other than for I''m-bleeding-edge-nyah-nyah-ness. ;-)> Thanks for the suggestion, though, it''s gotten me one step further > along.No worries, will be interested to see if you get it working! Easiest method, I reckon, is just to send it as text/html from your controllers, using .rxml views, and putting standard HTML embedded stylesheet stuff in them. Kinda gets you the best of all worlds, currently, in a way that will work with all browsers. ~Dave -- Dave Silvester Rent-A-Monkey Website Development Web: http://www.rentamonkey.com/
Dave Silvester wrote:> So essentially, you need to use content negotiation to give the > browser what it prefers.Nope. No way. Nuh-Uh.> Whatever, you''re not going to be able to get this to work in IE using > xml-stylesheet directives, AFAIK, because IE sucks at this kind of > stuff.Gonna spend a little time on this. Explorer seems to download the stylesheet correctly as ''text/xml'' but not ''text/html''.> ... although then I guess you''d still need content negotiationI said no and I mean it!> Ultimately, I think you can do what you want to do by sending it as > text/html, > and using regular XHTML embedded stylesheet stuff rather than > xml-stylesheet directives.That''s my next test. At this point it looks like I''ve duplicated all the headers from the Perl app that works fine in Explorer and uses embedded styles. Stylesheets are the only difference.> Or figure out content negotiation in Rails,Now am I going to have to get physical here?...> I reckon it would actually be quite > easy (and undoubtedly neater - PHP kinda grosses me out these days!)Eeew! I hate it when you step in a pile of syntax!> Easiest method, I reckon, is just to send it as text/html from your > controllers, using .rxml views, and putting standard HTML embedded > stylesheet stuff in them.That the way I was leaning, but I still want to figure out what I can and cannot do in Explorer. Kirk -- Posted via http://www.ruby-forum.com/.
On Wednesday 28 Dec 2005 20:35, Kirk Bocek wrote:> Nope. No way. Nuh-Uh. > I said no and I mean it! > Now am I going to have to get physical here?...Are you sure you haven''t mistaken content negotiation for user-agent sniffing? Just in case you thought I was advocating user-agent sniffing ("pure evil"), they''re two rather different things. As far as I know, there''s nothing inherently bad with content negotiation. If you''re trying to do something a bit more bleeding edge and it''s not supported by older browsers (and you have an easy way of downgrading it to give them something that works), then there''s nothing inherently bad about that, IMO. Browser sniffing on the other hand... eouw! Not that the thing I did on www.rentamonkey.com is particularly good code, or even has any point to it at the moment - it was slightly experimental, but I wanted to do it with a view to being fully XHTML 1.1 for clients that support it, and eventually dropping XHTML 1.0 at some point, although I suspect I''ll have re-built that site in Rails long before that ever happens.> Gonna spend a little time on this. Explorer seems to download the > stylesheet correctly as ''text/xml'' but not ''text/html''.I was going to ask why you''re sending the stylesheet as anything but text/css (which would work in IE, but not Gecko-based browsers), but then I realised you meant that the stylesheet would download when the page was sent as text/xml but not text/html, and that you were sending the stylesheet as text/css all along. :-)> That''s my next test. At this point it looks like I''ve duplicated all the > headers from the Perl app that works fine in Explorer and uses embedded > styles. Stylesheets are the only difference.I don''t know if you''re using xml-stylesheet directives or standard HTML embedded stylesheet tags, but I would suggest you probably should send the page as text/html and use regular stylesheet tags, not xml-stylesheet directives. That should definitely work, and is the same as what a .rhtml template would do, with the exception that you''re using .rxml to generate it, and the controller to change the content type of the page. I think the problem is that, AFAIK, IE won''t work with XML using a text/css stylesheet, because it''s expecting a text/xsl one, and I guess that''s one of the things you''re coming up against. I could be wrong though - it''s been a while since I''ve done any of this stuff, and especially not in IE.> Eeew! I hate it when you step in a pile of syntax!<shudders> at the things I used to do in PHP.> That the way I was leaning, but I still want to figure out what I can > and cannot do in Explorer.Sounds to me like you''ve figured it out already . ;-) ~Dave -- Dave Silvester Rent-A-Monkey Website Development Web: http://www.rentamonkey.com/
Dave Silvester wrote:> Are you sure you haven''t mistaken content negotiation for user-agent > sniffing? > Just in case you thought I was advocating user-agent sniffing ("pure > evil"), > they''re two rather different things.Yes, I did make that mistake. I assumed they were two aspects of the same solution.> Sounds to me like you''ve figured it out already . ;-)You''re too kind. No really -- be less kind to me. Kirk -- Posted via http://www.ruby-forum.com/.
A short update: Explorer *does* download style sheets through the <link ...> tag. It does not, however, use the <?xml-stylesheet ... > declaration. This code in my .rxml document is working: xml.head { xml.title ''My XML Builder Test Page'' xml.link :type=>"text/css", :rel=>"stylesheet", href=>"/stylesheets/style-xml.css" } Kirk -- Posted via http://www.ruby-forum.com/.