From: Kevin M. Rosenberg Date: Mon, 17 Nov 2003 17:19:11 +0000 (+0000) Subject: r8241: rework doctype generator X-Git-Tag: v1.96~106 X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=commitdiff_plain;h=1738d41053dae41266d5740385be9aac03a864ad r8241: rework doctype generator --- diff --git a/impl.lisp b/impl.lisp index c6aa65d..c2d7cab 100644 --- a/impl.lisp +++ b/impl.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Sep 2003 ;;;; -;;;; $Id: io.lisp 7795 2003-09-10 05:44:47Z kevin $ +;;;; $Id$ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; diff --git a/xml-utils.lisp b/xml-utils.lisp index 36cd4e7..a9d641e 100644 --- a/xml-utils.lisp +++ b/xml-utils.lisp @@ -104,65 +104,73 @@ and position of character following end tag." (format nil " standalone=\"~A\"" standalone) ""))) -(defun dtd-stream (stream format &key name public-id system-id entities) - (case format - ((:xhtml11 :xhtml :xhtml10-strict :xhtml10-transitional :xhtml-frameset) - (setq name "html")) - (:html - (setq name "HTML")) - ((:docbook :docbook42) - (unless name - (setq name "book")))) +(defun doctype-stream (stream top-element availability registered organization type + label language url entities) + (format stream " stream) + (write-char #\newline stream)) +(defun doctype-format (stream format &key top-element (availability "PUBLIC") + (registered nil) organization (type "DTD") label + (language "EN") url entities) (case format - (:html - (unless public-id - (setq public-id "-//IETF//DTD HTML//EN")) - (setq system-id nil)) ((:xhtml11 :xhtml) - (unless public-id - (setq public-id "-//W3C//DTD XHTML 1.1//EN")) - (unless system-id - (setq system-id "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"))) + (doctype-stream stream "html" availability registered "W3C" type "XHTML 1.1" language + (if url url "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd") + entities)) (:xhtml10-strict - (unless public-id - (setq public-id "-//W3C//DTD XHTML 1.0 Strict//EN")) - (unless system-id - (setq system-id "http://www.w3.org/TR/xhtml10/DTD/xhtml10-strict.dtd"))) + (doctype-stream stream "html" availability registered "W3C" type "XHTML 1.0 Strict" language + (if url url "http://www.w3.org/TR/xhtml10/DTD/xhtml10-strict.dtd") + entities)) (:xhtml10-transitional - (unless public-id - (setq public-id "-//W3C//DTD XHTML 1.0 Transitional//EN")) - (unless system-id - (setq system-id "http://www.w3.org/TR/xhtml10/DTD/xhtml10-transitional.dtd"))) - (:xhtml10-frameset - (unless public-id - (setq public-id "-//W3C//DTD XHTML 1.0 Frameset//EN")) - (unless system-id - (setq system-id "http://www.w3.org/TR/xhtml10/DTD/xhtml10-frameset.dtd"))) + (doctype-stream stream "html" availability registered "W3C" type "XHTML 1.0 Transitional" language + (if url url "http://www.w3.org/TR/xhtml10/DTD/xhtml10-transitional.dtd") + entities)) + (:xhtml-frameset + (doctype-stream stream "html" availability registered "W3C" type "XHTML 1.0 Frameset" language + (if url url "http://www.w3.org/TR/xhtml10/DTD/xhtml10-frameset.dtd") + entities)) + (:html2 + (doctype-stream stream "HTML" availability registered "IETF" type "HTML" language url entities)) + (:html3 + (doctype-stream stream "HTML" availability registered "IETF" type "HTML 3.0" language url entities)) + (:html3.2 + (doctype-stream stream "HTML" availability registered "W3C" type "HTML 3.2 Final" language url entities)) + ((:html :html4) + (doctype-stream stream "HTML" availability registered "W3C" type "HTML 4.01 Final" language url entities)) ((:docbook :docbook42) - (unless public-id - (setq public-id "-//OASIS//DTD DocBook XML V4.2//EN") - (unless system-id - (setq system-id "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"))))) - - (format stream " stream) - (write-char #\newline stream) - stream) + (doctype-stream stream (if top-element top-element "book") + availability registered "OASIS" type "Docbook XML 4.2" language + (if url url "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd") + entities)) + (t + (unless top-element (warn "Missing top-element in doctype-format")) + (unless organization (warn "Missing organization in doctype-format")) + (unless label (warn "Missing label in doctype-format")) + (doctype-stream stream top-element availability registered organization type label language url + entities)))) + (defun sgml-header-stream (stream format &key entities (encoding "iso-8859-1") standalone (version "1.0") - name public-id system-id) + top-element (availability "PUBLIC") registered organization (type "DTD") + label (language "EN") url) (when (in format :xhtml :xhtml11 :xhtml10-strict :xhtml10-transitional :xhtml10-frameset :xml :docbook) (xml-declaration-stream stream :version version :encoding encoding :standalone standalone)) (unless (eq :xml format) - (dtd-stream stream format :name name :public-id public-id :system-id system-id - :entities entities)) + (doctype-format stream format :top-element top-element + :availability availability :registered registered + :organization organization :type type :label label :language language + :url url :entities entities)) stream)