W3C validation of CL-HTTP's XHTML 1.0 output

"Chun Tian (binghe)" <[email protected]> Thu, 24 Mar 2011 19:57:36 +0800
Newsgroups gmane.lisp.cl-http
Message-ID <[email protected]>
--Apple-Mail-6-538109090
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

Hi, CL-HTTP Developers

Currently CL-HTTP's XHTML 1.0 output cannot pass W3C validation service =
[1], because several HTML tags are not self-closed, like <br>, <hr>, =
<img ...>, ... they should be written as <br/>, <hr/>, <img .../>, ...

To fix this, I think the macro %ISSUE-COMMAND from HTML2.0 package =
should be rewritten in HTML4.0 package, in which there is a =
*XHTML-GENERATION*  special variable, which will be bound to T when =
doing XHTML generations:

(defmacro %issue-command ((command stream &key fresh-line trailing-line) =
&body argument-body)
  `(progn
     ,.(when fresh-line
         `((fresh-line ,stream)))
     (write-char #\< ,stream)
     (write-string ,command ,stream)
     ,@argument-body
     (when *xhtml-generation*      ; here, output an additional #\/
       (write-char #\/ ,stream))   ; when doing XHTML generation
     (write-char #\> ,stream)
     ,.(when trailing-line
         `((fresh-line ,stream)))))

The only exception is in XHTML1.0:DECLARE-HTML-VERSION, in which =
following DOCTYPE declaration was generated:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" =
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

it must NOT be a self-closed tag. So *XHTML-GENERATION* should be bound =
to NIL specially in this function.

With all these changes, I believe CL-HTTP's XHTML1.0 outputs can pass =
W3C validation service's check.

Full patch is in attach, I'm afraid that this change cannot be made into =
a loadable patch.

Regards,

Chun Tian (binghe)

[1] http://validator.w3.org/


--Apple-Mail-6-538109090
Content-Disposition: attachment;
	filename=xhtml1.patch
Content-Type: application/octet-stream;
	name="xhtml1.patch"
Content-Transfer-Encoding: 7bit

Index: cl-http/server/html4.lisp
===================================================================
--- cl-http/server/html4.lisp	(revision 37)
+++ cl-http/server/html4.lisp	(working copy)
@@ -39,7 +39,20 @@
 (eval-when (:compile-toplevel :execute :load-toplevel)
 (defvar *strict-dtd* nil
   "Non-null when generating strict HTML 4.")
-)
+
+(defmacro %issue-command ((command stream &key fresh-line trailing-line) &body argument-body)
+  `(progn
+     ,.(when fresh-line
+         `((fresh-line ,stream)))
+     (write-char #\< ,stream)
+     (write-string ,command ,stream)
+     ,@argument-body
+     (when *xhtml-generation*
+       (write-char #\/ ,stream))
+     (write-char #\> ,stream)
+     ,.(when trailing-line
+         `((fresh-line ,stream)))))
+) ; eval-when
 
 (define declare-html-version (&optional (stream *output-stream*) (dtd-version :frameset))
   "Declares the document type as the current HTML generation DTD.
Index: cl-http/server/package.lisp
===================================================================
--- cl-http/server/package.lisp	(revision 37)
+++ cl-http/server/package.lisp	(working copy)
@@ -970,6 +970,7 @@
   (:nicknames "HTML")
   (:shadow
    "%WRITE-COMMAND-KEY-ARG"
+   "%ISSUE-COMMAND"
    "*DTD-VERSION*"
    "ACCEPT-INPUT"
    "APROPOS-ISO-CHARACTER"
@@ -1641,7 +1642,6 @@
         "*SECTION-LEVEL*"                            ;interoperate between different packages
         "*SELECT-CHOICES-MAX-DEFAULT-SIZE*"
         "*SPECIAL-CHARACTER-TRANSLATION-ALIST*"
-        "%ISSUE-COMMAND"
         "%WITH-ENVIRONMENT"
         "CHECK-VALUE-TYPE"
         "FILE-UPLOAD-MAKE-QUERY"
Index: cl-http/server/xhtml1.lisp
===================================================================
--- cl-http/server/xhtml1.lisp	(revision 37)
+++ cl-http/server/xhtml1.lisp	(working copy)
@@ -20,11 +20,6 @@
 
 (in-package :xhtml1.0)
 
-(mapc #'(lambda (x) (import (intern x :html4.0) :xhtml1.0))
-      '("%ISSUE-COMMAND"
-        "%WRITE-COMMAND-KEY-ARG"
-        "%MAKE-WITH-HTML-DOCUMENT-ENV"))
-
 ;;;------------------------------------------------------------------- 
 ;;;
 ;;;  DOCUMENT LEVEL OPERATIONS
@@ -47,7 +42,8 @@
 (defun %write-xml-namespace-arg (stream namespace-url)
   (%write-command-key-arg stream "xmlns" namespace-url))
 
-(define declare-html-version (&optional (stream *output-stream*) (dtd-version :frameset))
+(define declare-html-version (&optional (stream *output-stream*) (dtd-version :frameset)
+                              &aux (html4.0::*xhtml-generation* nil))
   "Declares the document type as the current HTML generation DTD.
 All XHTML 1.0 document must declare the document type definition version.
 

--Apple-Mail-6-538109090
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
WWW-CL mailing list
[email protected]
https://lists.csail.mit.edu/mailman/listinfo/www-cl

--Apple-Mail-6-538109090--