Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: CSV or HTML?

by tobyink (Abbot)
on Jan 19, 2012 at 10:47 UTC ( #948752=note: print w/ replies, xml ) Need Help??


in reply to Re: CSV or HTML?
in thread CSV or HTML?

Shame it wraps the CSS in that cargo cult <!-- --> nonsense. This was kinda useful for a few browsers in the mid-1990s, but is actively harmful today.

In XML DTDs (including the DTD for XHTML 1.1), there is no mechanism to specify that the content model for an element is CDATA. Thus the <!-- --> acts as a genuine XML comment, and causes the style sheet contained within it to be commented out and totally ignored.

If a browser is in HTML mode (i.e. you serve the page using Content-Type: text/html) you won't notice this, but as soon as you switch to Content-Type: application/xhtml+xml all your styles will disappear.

Illustration...

<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>CSS demo</title> <style type="text/css"> p { color: green } </style> <style type="text/css"><!-- p.mine { color: red } --></style> </head> <body> <p class="mine">This should be green.</p> </body> </html>

The above, viewed in a standards compliant browser, in XHTML mode, will show a green paragraph. The CSS which sets it to red is commented out and ignored.


Comment on Re^2: CSV or HTML?
Select or Download Code
Re^3: CSV or HTML? (now OT)
by ww (Bishop) on Jan 19, 2012 at 12:36 UTC
    ...and the name of "a standards compliant browser" (to which to your refer) is?

    I ask because I don't really believe there is such a thing.

    Tangent: Using the phrase "standards compliant" (yeah, I'm guilty too) tends to obscure the issue -- IMO -- which arises from the fact that "standards compliant" is not the same as "implements all of whichever relevant standard one might select."

    There is, for example, a "standard" (and right now I've forgotten whether its CSS or html4.1) providing a way to align a mixed length set of decimal numbers*1 in a column of <td>s in a <table> (it applies to other things too, but that's easy to grasp.

    That would be a very handy standard to follow... except that no browser (of which I'm aware) actually implements it. Yes, there are workarounds, but as is often the case, those workarounds are often a PITA.

    *1 Example of the mixed length set of:

         1.01234
         101.234
         101.00
         10123.4
    

    One common workaround, aligning the column rightward, doesn't work there, but some means of aligning the decimal points sure would make it easier to read.

      ...and the name of "a standards compliant browser" (to which to your refer) is?

      I ask because I don't really believe there is such a thing.

      There is only one reference browser: amaya. But you'd be a serious masochist if you actually use it :).

      I'm curious what that mixed alignment setting would be: I cannot find it in my CSS3 reference.


      Enjoy, Have FUN! H.Merijn

        Tux: Not the canonical reference but in http://www.w3.org/MarkUp/html3/tables.html there is this:

        Hint: You can achieve a similar effect to the above by using decimal alignment and using the DP attribute to set the alignment character to a convenient character, for example:
        <table> <tr align=decimal dp=":"> <td> name: <input name="name" size=18><br> card number: <input name="cardnum" size=18><br> expires: <input name="expires-month" size=2> / <input name="expires-year" size=2><br> telephone:<input name="phone" size=18><br> </table>
        Each line in the table is then indented so that all the colons are positioned under one another.

        And yes, Amaya is a reference browser, but that doesn't change it's incompleteness (acknowledged with respect to CSS, for example, at http://www.w3.org/Amaya/Amaya.html at the heading "Support for CSS").

        BTW, I have used it and while it sure is painful to do so, I'm not sure I'd characterize myself as a masochist. Excuse me now, while I go back to reading some nearly unintelligible nodes. :-)

      ...and the name of "a standards compliant browser" (to which to your refer) is?

      For the purpose of my example, any version of Opera, Mozilla or Safari released in the last decade should do, as should IE9.

      Sure there are plenty of holes in standards compliance in browsers, but this particular standard (parsing XHTML) is pretty reliably implemented.

        "Re^2: CSV or HTML?
        by tobyink on Jan 19, 2012...
        .... (Illustration & other narrative, omitted. ....
        The above, viewed in a standards compliant browser, in XHTML mode, will show a green paragraph. The CSS which sets it to red is commented out and ignored.

        and, in the parent of this node

        For the purpose of my example, any version of Opera, Mozilla or Safari released in the last decade should do, as should IE9.

        Did you intend to exclude FF from your list because it doesn't satisfy your standards for "standards compliant" or simply because three examples, with a fourth as an afterthought, seemed adequate to lead the reader to infer that you mean any widely distributed browser, Y2k or a bit more recent, will fill the bill?

        If so, then once again I seem to be missing something.

        Using your "Illustration" xhtml, verbatim, in a file called "xhtml_test.xhtml", serving it from Xitami on a win32 box, and browsing it in what FF 9.01 claims is "Standards Compliant Mode," I see the supposedly green para in red.

        Adding <meta http-equiv="Content-Type: application/xhtml+xml"> immediately after the dtd does NOT change the rendering.

        Want to take another shot at pointing me in the right direction?
            (I hope.)

      I believe that something along these lines would have worked at one time...

      <style> .mlx-test-align tr td { text-align: "."; } </style> <table class="mlx-test-align"> <tr><td>1.01234</td></tr> <tr><td>101.234</td></tr> <tr><td>101.00</td></tr> <tr><td>10123.4</td></tr> </table>
      ... but according to the blooberry CSS reference (IME, a fairly reliable summary of the various aspects of the CSS and HTML specs),
      The [string] value type has been removed in CSS2.1.
      I was not able to produce the correct alignment using text-align, but that may speak more of my capabilities than the capabilities of my browsers.

      Rather a shame, as aligning to a character has some useful applications.

      Update: It appears that another blooberry page has some possibly updated information (testing below...)

      Example from w3.org
      Vegetable Cost per kilo
      Lettuce $1
      Silver carrots $10.50
      Golden turnips $100.30

      I am not able to reproduce their results. My guess is that I didn't set the document type correctly.

      --MidLifeXis

        There's a statement on http://www.w3schools.com/tags/att_td_char.asp, a w3cschools page with a 2012 copyright (though that may be a mere boiler-plate footer) that "The char attribute is not supported by any of the major browsers."

        My guess is that has more to do with reproducing their results than your doctype setting. When I have a bit more free time, I should probably grab a current version of Amaya and see how it fares (or, perhaps, some other 'masochist'-- see Tux's above -- would like to report some findings).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://948752]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-09-01 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (299 votes), past polls