I have a dynamically generated HTML document that includes a table
of numbers. In this table, I want every number greater than some
numerical parameter MAX_VAL (also dynamically generated) to be
rendered as "> " followed by the string form of MAX_VAL. For
example, if MAX_VAL is 1000, and a row in this table consists of
the numbers 500, 1000, and 200, i.e.
<TR>
<TD CLASS="nifty" MAX_VAL=1000>500</TD>
<TD CLASS="nifty" MAX_VAL=1000>1000</TD>
<TD CLASS="nifty" MAX_VAL=1000>2000</TD>
</TR>
I want that row to be rendered like this:
| 500 | 1000 | > 1000 |
Can this be done with CSS? It would require at least three things
I don't know how to do:
* First, the CSS would have to be able to work with a user-defined
parameter (in this case MAX_VAL).
* Second, it would have to be able to produce different styles
conditional on the value of this parameter.
* And third, one of these styles must be able to incorporate the
string version of this user-defined parameter in the generated
output.
Is this a pipe dream?
Any clues on how this can be done would be much appreciated.
Thanks in advance!
kj

Signature
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
David Dorward - 24 Apr 2006 21:28 GMT
> I have a dynamically generated HTML document that includes a table
> of numbers. In this table, I want every number greater than some
[quoted text clipped - 8 lines]
> <TD CLASS="nifty" MAX_VAL=1000>2000</TD>
> </TR>
This is not an HTML document as no version of HTML has a "MAX_VAL"
attribute.
> I want that row to be rendered like this:
>
> | 500 | 1000 | > 1000 |
>
> Can this be done with CSS?
No.
> * First, the CSS would have to be able to work with a user-defined
> parameter (in this case MAX_VAL).
CSS can work with generic XML documents, so this isn't a problem (assuming
you started using XML)
> * Second, it would have to be able to produce different styles
> conditional on the value of this parameter.
Attribute selectors let you do this (although only on pattern matching,
maths isn't possible with them).
> * And third, one of these styles must be able to incorporate the
> string version of this user-defined parameter in the generated
> output.
This is possible with the content property. (Well, ish).
You also would need the ability to process the content of the element.
> Any clues on how this can be done would be much appreciated.
Transform it on the server and output the content you want to display.

Signature
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
KMA - 25 Apr 2006 09:49 GMT
Just an idea, but can't you get the server side generator to use two
classes, "nifty" and "Bignifty", then css can highlight the Bigniftys.
> I have a dynamically generated HTML document that includes a table
> of numbers. In this table, I want every number greater than some
[quoted text clipped - 33 lines]
>
> kj
dingbat@codesmiths.com - 25 Apr 2006 10:39 GMT
> Can this be done with CSS?
No.
It might almost be possible using attribute selectors, _IF_ your
problem were only a little simpler and just required an equality test,
not a comparison. However even then you'd be relying on CSS features
of recent spec versions that aren't widely supported. It wouldn't work,
it wouldn't work if CSS was unavailable, it wouldn't work on older
browsers, it wouldn't be at all accessible and most of all it's pretty
contrary to the whole ethos of CSS.
Don't use CSS to mess with content. Use it to present content that you
already have.
I'd suggest some scripting (ideally server-side, but client side would
be OK) that sets a class attribute value of "max-exceeded" onto the
rows >MAX_VAL. CSS could then colour these rows accordingly.
CSS _could_ even change the presentation of the large value into
invisiblilty and a flat text warning message "> MAX", if this class was
set. This would be possible, even quite easy to do, but it wouldn't be
portable (IE is still too broken and too commonplace). Technically
you could do this, practically you shouldn't.
Bruce Lewis - 25 Apr 2006 15:53 GMT
> <TR>
> <TD CLASS="nifty" MAX_VAL=1000>500</TD>
[quoted text clipped - 7 lines]
>
> Can this be done with CSS?
That's a perfectly fair question. CSS is about presentation, and what
you're specifying is presentation.
But from a CSS standpoint, what you're specifying is content. It's
better not to try to do it with CSS.
You've stumbled upon an important point that is often missed. Many
server-side frameworks out there seek to enforce that presentation
specification and logic/content specification stay on their own sides of
the line. The problem is, often there's no line.

Signature
http://ourdoings.com/ Easily organize and disseminate news and
photos for your family or group.