You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Brian Behlendorf <br...@organic.com> on 1996/02/11 23:23:33 UTC

Re: conditional HTML

On Sun, 11 Feb 1996, Dean Gaudet wrote:
> Should I clean up HotWired's conditional html code and submit it?
> It requires a patched Bison to even build it.  It also has a scanner
> I'm not overly proud of.  Last time I talked about it here I got the
> feeling you (plural) weren't interested in it... I'm fairly certain
> that the syntax bothers at least Brian :)
...
> I'm willing to give the code to someone else who has the time to
> change it to whatever you guys decide you want it to look like.

Here's my take.  The lack of HTTP content negotiation to be able to deal 
with microvariants within content types (i.e., new vendor-specific tags 
to HTML) means that we will probably see some form of conditional HTML 
that gets shipped to the client, where the conditional expansion 
happens.  This is much more friendly on servers (who then don't have to 
do the user-agent comparison (thanks, microsoft!) and *especially* 
friendly on caches, which then don't have to keep copies of html pages 
tailored for every client in even the best case.  Conditional HTML will 
basically be a formalization of the functionality one sees with 
<EMBED><NOEMBED> - a client is "aware" of a couple major feature sets it 
supports, and can switch on those feature sets.

Content negotiation *will* be used to distinguish between HTML with the 
conditional functionality, and regular old HTML, for purposes of 
backwards compatibility.  The most graceful thing to do for browser which 
don't support conditional HTML is to have a module which parses it for 
them, using a lookup table of browsers and known feature sets they 
support.

What will this conditional HTML look like?  Keeping HTML a conformant 
application of SGML is still considered a Good Thing, so using special 
tags like <if>, <else>, etc is not recommended.  The two mechanisms in 
SGML which could provide for this are marked sections or processing 
instructions.  Marked sections would look something like this (to switch 
on, say, tables)

<![ %FEATURE.hasTables; [ 
<TABLE> .... </TABLE> 
]]>

<![ %NOT.hasTables; [
<PRE> .... </PRE>
]]>

By default all entities beginning with "FEATURE" could resolve to false, 
since in SGML unknown entities resolve to true.  I have been assured by 
SGML gurus that the regular "NOT", "AND", and "ELSIF" functionality can 
be accomplished this way.

Processing instructions are a little less ugly, but less well defined by 
SGML.  Basically they are tags which begin with a ?, and it's left up to 
the browser or spec to specify what to do with them.  I.e.

<?IF cond="condition"> 
<?ELSIF>
<?ENDIF>

etc.  The SGML purists don't like it as much because documents become 
harder to parse (DTD's alone can't describe the proper semantics) so 
having two different <BODY> tags would be illegal.  Or maybe I have this 
completely wrong, I don't know.  I do know it's important to keep it 
simple enough that people will want to use it, and PI's might be the best 
bet.

Marc Hedlund and I are trying to get together people interested in 
formulating a proposal... I think it would be best if the Apache group 
did not endorse a particular conditional-HTML format until we have one 
we're reasonably sure will be the one used client-side as well.  
Otherwise we have a mess of people saying "we've been doing it this one 
way for awhile now, we have thousands of documents in this format, we 
don't want to switch!"  Unless, of course, we could write a converter....

	Brian

--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
brian@organic.com  brian@hyperreal.com  http://www.[hyperreal,organic].com/


Re: conditional HTML

Posted by ra...@madhaus.utcs.utoronto.ca.
> Processing instructions are a little less ugly, but less well defined by 
> SGML.  Basically they are tags which begin with a ?, and it's left up to 
> the browser or spec to specify what to do with them.  I.e.
> 
> <?IF cond="condition"> 
> <?ELSIF>
> <?ENDIF>

I have written a server-side html-embedded scripting language called
PHP/FI that is used by quite a few sites on the Net now.  I by no means
think it should become any sort of standard, but I do think it serves
as a good example of what can be done with such a language.  

I went back and forth on the question of what to use as the initiator
tag as well.  I ended up going with the SGML PI tag, even though most
browsers have no clue what to do with them if they do manage to slip
through unparsed.  Here is some example code which displays a list of
files in a table.  The actual file information is read right out of
a directory with opendir() and readdir() calls in a while loop.  
A regular expression match is done on the filenames to figure out if
they are valid (.gz or .zip) and an appropriate icon is used to
represent the file.  Then at the bottom an RFC-1867 File Upload form
is presented and users who know the upload password may go ahead
and upload files directly to the upload directory.  More information
on PHP/FI can be found at http://www.io.org/~rasmus if you are interested.
The site is currently being completely re-written and moved to
http://www.vex.net/php, so you may want to check there as well.  The
actual file upload page is only on vex.net.

<?
	$file_dir = "files";
	opendir($file_dir);
	$entry = readdir();
	$i=0;
	while($entry);
		$dir[$i] = $entry;
		$type[$i]=0;
		if(reg_match(".*\.gz$",$entry));	
			$type[$i] = 1;
			$i++;
		elseif(reg_match(".*\.zip$",$entry));	
			$type[$i] = 2;
			$i++;
		endif;
		$entry = readdir();
	endwhile;
	$num = $i>
	<center><table border=2>
	<?if($num==0); echo "<caption>No Files!</caption><p>";
	elseif($num==1); echo "<caption>1 File</caption><p>";
	else; echo "<caption>$num Files</caption><p>"; endif>
	<tr><th></th><th>Filename</th><th>Size</th><th>Date</th>
	<th>Description</th></tr>
	<?$i=0;
	while($num && $i < $num);
		if($type[$i] == 1)>
			<tr><td align=center>
			<img src="/php/gifs/filegz.gif" hspace=2></td>
		<?elseif($type[$i] == 2)>
			<tr><td align=center>
			<img src="/php/gifs/filezip.gif"></td>
		<?endif>
		<td align=center>
		<?echo "<a href=\"/php/files/$dir[$i]\">$dir[$i]</a></td>";
		echo "<th>";
		echo fileSize("$file_dir/$dir[$i]");
		echo "</th><th>";
		echo Date("M d/y H:i:s",fileMtime("$file_dir/$dir[$i]"));
		echo "</th>";
		$fp = @fopen("$file_dir/$dir[$i].info","r");
		echo "<td align=left>";
		if($fp != -1);
			$line = fgets($fp,100);
			while($line);
				echo $line;
				$line = fgets($fp,100);
			endwhile;	
		else;
			echo "none";
		endif;
		echo "</td></tr>";
		$i++;
	endwhile;
	echo "</table></center>">
	<p><hr>
	<center>
	<form action="/php/receive.phtml" 
		enctype="multipart/form-data" method=POST>
	Upload password: <input type="password" name="pw"><br>
	<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
	Filename: <input type="file" name="filename"><br>
	Description<br>
	<textarea name="description" rows=3 cols=30></textarea><br>
	<input type="submit" value=" Send File ">
	</form></center>