W3C home > Mailing lists > Public > www-html@w3.org > July 2008

Re: XHTML Basic 1.1 and setting input field to numeric mode

From: Luca Passani <passani@eunet.no>
Date: Tue, 01 Jul 2008 11:35:37 +0200
Message-ID: <4869FA69.30503@eunet.no>
To: Benjamin Hawkes-Lewis <bhawkeslewis@googlemail.com>
CC: Mark Birbeck <mark.birbeck@webbackplane.com>, Tina Holmboe <tina@greytower.net>, Shane McCarron <shane@aptest.com>, "Michael(tm) Smith" <mike@w3.org>, www-html@w3.org

Benjamin Hawkes-Lewis wrote:
> Luca Passani wrote:
>> This is absolutely fantastic. Your code makes my point exactly.
>
> I'm not sure how. Looks to me like both sets of code do the same loops 
> and calculations. Just that one outputs the styles into a different 
> place and one outputs them into the same place as the markup. It's not 
> like JSTL doesn't have variable assignment capability. 
Look again.

Your code (for fairness to you, I will strip out the part that creates 
the mockup data):


$i           = 0;
$pairs_css   = '';
$pairs_xhtml = '';

foreach( $pairs as $pair ) {
    $i++;
    $id           = 'image-pair-'.$i;
    $pair_width   = $pair[0]['width'] + $pair[1]['width'];
    $pairs_css   .= '#'.$id.'{width:'.$pair_width.'px;}';
    $pairs_xhtml .= '<div id="'.$id.'">';

    foreach ( $pair as $image ) {
        $pairs_xhtml .= '<img src="'
                        .htmlentities( $image['url'] )
                        .'" width="'
                        .$image['width']
                        .'" height="'
                        .$image['height']
                        .'" alt="'
                        .htmlentities(
                             $image['text_equivalent'],
                             ENT_QUOTES
                         )
                        .'" />';
    }

    $pairs_xhtml .= '</div>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
    "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; 
charset=utf-8" />
<title>Image pairs</title>
<style type="text/css"><![CDATA[<?php echo $pairs_css; ?>]]></style>
</head>
<body>
<h1>Image pairs</h1>
<?php echo $pairs_xhtml; ?>
</body>
</html>

Now look at mine:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
   "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; 
charset=utf-8" />
<title>Image pairs</title>
</head>
<body>
<h1>Image pairs</h1>
<c:forEach var="pair" items="${pairs}">
<div style="width:${pair[0].width+pair[1].width}">
 <c:forEach var="image" items="${pair}">
    <img src="${image.url}" width="${image.width}" 
height="${image.height}" alt="${image.textEquivalent}">
 </c:forEach>
</div>
</c:forEach>
</body>
</html>

My code is separating content from presentation for real. Your code 
isn't. Your code is a mess. And the difference is that I am using 
@style, while you are desperately trying to do without it.
If you say you can't see the difference, you are in bad faith.

 > It's not like JSTL doesn't have variable assignment capability.

what do you mean? are you suggesting that it's possible to write poor 
code in JSTL too?
of course. My point is that the lack of @style may force people to write 
poor code in many instances.

Luca
Received on Tuesday, 1 July 2008 09:36:29 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:16:14 GMT