Jack McKalling Posted July 17, 2010 Share Posted July 17, 2010 Hello, I have a problem. Why am I so incredibly late to find this problem in my development... Could you help me?In short, I seem not able to such a simple thing as adding custom entities to my Xhtml 1.0 doctype. None of the browsers support internal subsets, they just render the closing "]>" chars at the end of the doctype element.But this is inconsistent to what I am reading on the net, and even in the W3C specification. It is specified, an internal subset IS allowed following an external one, here: http://www.w3.org/TR/REC-xml/#NT-doctypedecl (unsure this is the right specification to look for this)See the following example: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" [ <!ENTITY test "Some replacement."> ]><html>...<body>&test;... But all I am seeing is "]>&test;"I suppose what I am trying to do is declaring shortcuts to common used HTML elements that clutter my html sourcecode.. I already know html should be allowed in an entity value, and an entity may be declared as an addition to the public xhtml dtd, but I can't get passed actually getting an entity to work. I notice the doctype is parsed until the browser gets to the first ">" sign, regardless if it is closing the doctype or an element in its internal subset, rendering the entity hopelessly ignored...An example of what I would like to create a shortcut of: <abbr title="Longer description of the acronym">acronym</abbr>Can anybody help me with this? Am I doing something wrong, or is there a better alternative, other than using a complete custom dtd that imports the complete public xhtml dtd? thanks*Edit:edited for publicity reasons Link to comment Share on other sites More sharing options...
Guest FirefoxRocks Posted July 17, 2010 Share Posted July 17, 2010 I'm not sure if browsers (IE, Firefox, Chrome, Safari) processes custom DTDs when documents are served as text/html. Actually, I don't even know if they process SGML doctypes in non-XML documents.You can try serving your page as applcation/xml or application/xhtml+xml (does not work in IE8 and below) to see if the custom doctype works ... maybe someone will be able to explain this better than me. Link to comment Share on other sites More sharing options...
Jack McKalling Posted July 17, 2010 Author Share Posted July 17, 2010 Thanks for your reply. I don't know how to serve my page as xml or anything else, but I do want it to work in IE7 too unfortunately.I tested it by downloading the dtd and editing it manually to add a general entity, and it indeed did not expand as feared.Is there some other way of doing this?If entities in a dtd are not expanded in a browser, then what ARE they for?! The Xhtml dtd doesn't declare any entity either, only parameter entities. Does that mean & and etc are defined in the character set? *noob* Link to comment Share on other sites More sharing options...
Jack McKalling Posted July 18, 2010 Author Share Posted July 18, 2010 Sorry, ofcource I know how to serve my page as another type, it was very late and I didn't understand what you meant by "serving as".I tried other mimetypes, but as expected, changing the contenttype does not affect the expansion of custom entities, unfortunately. Link to comment Share on other sites More sharing options...
boen_robot Posted July 18, 2010 Share Posted July 18, 2010 Are you sure the MIME type was changed? If it failed to work in IE8 and below, then it worked, but if it worked, then you haven't changed the MIME type.Try to save the following with an ".xhtml" extension (to trigger the application/xhtml+xml MIME type): <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" [ <!ENTITY test "Some replacement."> ]><html xmlns="http://www.w3.org/1999/xhtml"><head><title>TEST</title></head><body><div>&test;</div></body></html> It works in all browsers I've tried... and it validates too (to my surprise to be honest).But yeah, if you need this to work in IE7, you'll have to scrap entities altogether. They are not supported in the text/html MIME type of any browser, even though they're part of the SGML spec. If you want to save yourself some typing time, using PHP is probably the best option here - just have the common parts in variables, and echo the variables instead of the full text. Link to comment Share on other sites More sharing options...
Jack McKalling Posted July 18, 2010 Author Share Posted July 18, 2010 Thanks, that information helped a lot.I am using PHP on a webserver, so I cannot actually change the file extension to other than .php, but a content-type header also works in Opera, Firefox and Chrome. Apparantly IE(7) needs the file extension, am I right?*Edit:So I was already using php, thanks When I said sourcecode, I actually meant the client-side one... It is not such a big deal, I can tell my application to put the values of those entities on aseparate line, and indent accordingly. I was just wondering if I am able to put some html in a custom entity, would be nice in my sourcecode lol.Like, having "&object;" somewhere in the body, that actually renders as a lightweight object with borderimages and rollover effect etc.. Link to comment Share on other sites More sharing options...
boen_robot Posted July 18, 2010 Share Posted July 18, 2010 Well, yeah... the moment you can safely abandon IE8 and below (a few years down the road), you'll be able to. Link to comment Share on other sites More sharing options...
Jack McKalling Posted July 18, 2010 Author Share Posted July 18, 2010 Ok, thanks. Weird that this has not been supported for such a long time, eventhough the ability to create custom entities existed.Browsers probably said to themselves "ahwell, my customers are probably not going to use that, so I'm not supporting it." Lazy thought Link to comment Share on other sites More sharing options...
boen_robot Posted July 18, 2010 Share Posted July 18, 2010 I think it was more like "if I support this, my customers will expect me to also support the other DTD features... let's see... oh no, that would be difficult to implement... that too... and that... OMFG... did the guy who wrote the spec ever considered that this thing must be implementable? Scrap DTDs!!!".Keep in mind that SGML includes a lot more features that save typing time and reduce document size, but they require the parser to implement DTD fully, and constantly check with it to ensure the feature is allowed here. Such features include implicit self closing tags (declare empty elements in the DTD, then just have an open tag, and the closing one is added; no need for an extra "/" at the start tag), minimized attributes (just declare the attributes that are minimizable, and if the word is encountered as an attribute, it's treated as an attribute with that value), omitting quotes around attributes without spaces and "=" in their values, automatically creating required enclosures in the tree if you omit them from source, etc. etc. Link to comment Share on other sites More sharing options...
Jack McKalling Posted July 18, 2010 Author Share Posted July 18, 2010 Didn't know that, actually don't know a lot about dtds in a technical manner at all. I know about modularization and Schema instead :)So, would it make a difference at all, if I used Schema instead of a DTD? Ofcource i'll need to write it my own, but if I that wasn't a problem, would my document have the same features, and validate? Link to comment Share on other sites More sharing options...
boen_robot Posted July 18, 2010 Share Posted July 18, 2010 In XML context, DTD is much worse choise than XML Schema, because it doesn't support namespaces, and (that's just a personal observation; not necesarily true) writing a DTD is somewhat more difficult for anything slightly more complex.However, XML Schema doesn't support entities (I'm guessing because entities are considered a parsing feature, whereas Schema operates as a separate feature), which is why the XHTML spec is using DTD. If you can live without the "©", " " and other named entities, you can switch your validation over to XML Schema (there's a reference XML Schema for XHTML in the spec). The W3C validator unfortunatly doesn't validate by Schema, so the "Valid" badges are out - your document will be "valid", but not according to the W3C validator. Link to comment Share on other sites More sharing options...
Jack McKalling Posted July 18, 2010 Author Share Posted July 18, 2010 Bummer :)Though I don't understand where those named entities come from. They are not in the DTD, I checked, I downloaded the physical file, and there is really none whatsoever. However they are indeed missing if the dtd is absent, according to the validator (or lovely Chrome who validates xhtml too).So that makes me wonder, where are they?If I can find the entities that a DTD supposedly provides, I might replicate them to regain © and etc.Are they in the characterset? What's got a DTD to do with it then? Link to comment Share on other sites More sharing options...
boen_robot Posted July 18, 2010 Share Posted July 18, 2010 They are in a separate file, included by the XHTML DTD. I'm not sure what it was, but it should part of the XHTML DTD's source and should end with ".ent".If you just include that file as the DTD, you'll have those named entities. You better hope no one picks up the document in validaing mode though. Without the rest of the DTD, parsing the XML file in validating mode would result in an error. Browsers don't parse in validating mode, so they should be OK.BTW, this exact approach with only using DTD for the entities is the approach XHTML 2.0 was going to take. Link to comment Share on other sites More sharing options...
Jack McKalling Posted July 18, 2010 Author Share Posted July 18, 2010 Found them :)xhtml-lat1.entxhtml-symbol.entxhtml-special.entNow let me see if I can do something about this, watch this space... Link to comment Share on other sites More sharing options...
Jack McKalling Posted July 18, 2010 Author Share Posted July 18, 2010 So using a schema would work in all browsers, but would not validate for me. That's actually very bad.Probably best to stick with a DTD then, I'll save the xhtml contentype solution for later, and scrap using entities for the while.I've managed enough in my sourcecode so I don't need them right now. Thanks for the help :)About Xhtml2, man that sounds attractive. I've read the intro in the specification, I specially love the new structuring and elements. But I guss its no standard right? Do browsers support it already? And could you explain to me what would be better, Xhtml(2) or HTML5? Link to comment Share on other sites More sharing options...
Ingolme Posted July 18, 2010 Share Posted July 18, 2010 XHTML 2 development was cancelled in favor of HTML 5. The specification is there still, if you look for it. To my knowledge, there's absolutely no browser support for XHTML 2. Link to comment Share on other sites More sharing options...
Jack McKalling Posted July 18, 2010 Author Share Posted July 18, 2010 But why, does it mean HTML5 should be favoured, or can we wait till xhtml2?I mean, html5 sounds terrible to me, and the launch of Xhtml excited me incredibly. Why revert back? Link to comment Share on other sites More sharing options...
boen_robot Posted July 18, 2010 Share Posted July 18, 2010 But why, does it mean HTML5 should be favoured, or can we wait till xhtml2?I mean, html5 sounds terrible to me, and the launch of Xhtml excited me incredibly. Why revert back?I feel the same way... I think there are several reasons browsers didn't want to adopt XHTML 2.0:1. XForms. No browser has native XForms support. Supporting XHTML 2.0 meant adding support for it in XHTML 2.0 mode, which is a very large and complicated spec. It is also the most useful one I've ever seen, but still... hard to implement apparantly. The closest thing to a native implementation was Mozilla's XForms extension (yes, an extension by Mozilla, for Mozilla; they didn't want to add actual native support before it's stable), but its latest version doesn't work with Firefox 3.6.2. Forcing the XHTML MIME type. Unlike XHTML 1.0, which could be served as both text/html and application/xhtml+xml, XHTML 2.0 is not backdraw compatible with HTML, thereby forcing the use of the XHTML MIME type. With IE not supporting application/xhtml+xml at the time, browser makers probably felt that having newer spec without IE being capable of degrading gracefully was useless. Now with IE9 upcoming, that part is probably less of a concern, but it probably still is somewhat.3. Too revolutionary. While the rendering engine itself doesn't have to be rewritten so much (since the styles are still done in CSS), it appears there some things that current HTML parsing engines take for constants, such as links being only on "a" elements. The fact that any element can be a link breaks this logic completely.On the bright side, HTML 5 will have an equivalent XML serialization, similar to what XHTML 1.0 was for HTML 4.01... I still hate the markup part as it currently stands though. Link to comment Share on other sites More sharing options...
Jack McKalling Posted July 18, 2010 Author Share Posted July 18, 2010 I just had a revolutionary idea!Lets all drop the old fashion IE, FF and Opera, put some more efford in Chrome to get it support Xhtml2.0, and then lets only use that browser! Link to comment Share on other sites More sharing options...
boen_robot Posted July 18, 2010 Share Posted July 18, 2010 I just had a revolutionary idea!Lets all drop the old fashion IE, FF and Opera, put some more efford in Chrome to get it support Xhtml2.0, and then lets only use that browser! I have a better idea. If YOU can (I can't...), recover the Mozilla XForms project, make it run on Firefox 3.6.6 and 4 beta, and then create an XHTML 2.0 extension that is dependant on that XForms module to display the XForms. This will then become the first "complete", open source implementation of XHTML 2.0, and it would show other vendors that the spec is actually implementable. If the code is portable enough, create a patch for WebKit for them to implement it, thereby giving this extension to Chrome and Safari. That would be the second and third implementation. Opera and IE are sure to follow if you can do this... W3C may even renew the XHTML 2.0 WG in this event.I'm suggesting you start with Firefox's XForms extension, because it's close to implementing the spec completely - much less work. Link to comment Share on other sites More sharing options...
Jack McKalling Posted July 18, 2010 Author Share Posted July 18, 2010 Good find, I'll let one of my slaves do just that. Expect the result in two decades, and some credit. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.