From 8c0facc594789945e9d7512c43ec6a3ab5780037 Mon Sep 17 00:00:00 2001 From: David Lichteblau Date: Sun, 27 Apr 2008 12:11:50 +0200 Subject: [PATCH] Implemented output/@media-type --- html.lisp | 7 +++++-- xslt.lisp | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/html.lisp b/html.lisp index dc75b33..38e3d6d 100644 --- a/html.lisp +++ b/html.lisp @@ -40,7 +40,8 @@ (defclass combi-sink (sax:content-handler) ((hax-target :initarg :hax-target :accessor sink-hax-target) (sax-target :initarg :sax-target :accessor sink-sax-target) - (encoding :initarg :encoding :accessor sink-encoding))) + (encoding :initarg :encoding :accessor sink-encoding) + (media-type :initarg :media-type :accessor sink-media-type))) (defmethod initialize-instance :after ((handler combi-sink) &key) (setf (sink-encoding handler) @@ -63,7 +64,9 @@ ((equal uri "") (sax:start-element hax-target *html* lname qname attrs) (when (and encoding (equalp lname "head")) - (let* ((content (format nil "text/html; charset=~A" encoding)) + (let* ((content (format nil "~A; charset=~A" + (or (sink-media-type handler) "text/html") + encoding)) (attrs (list (hax:make-attribute "http-equiv" "Content-Type") (hax:make-attribute "content" content)))) diff --git a/xslt.lisp b/xslt.lisp index 0f808ab..5b69c2b 100644 --- a/xslt.lisp +++ b/xslt.lisp @@ -967,7 +967,8 @@ doctype-system doctype-public cdata-section-matchers - standalone-p) + standalone-p + media-type) (defun parse-output! (stylesheet env) (dolist ( (list-toplevel "output" )) @@ -983,9 +984,7 @@ standalone cdata-section-elements) - (declare (ignore version - ;; FIXME: - media-type)) + (declare (ignore version)) (when method (multiple-value-bind (local-name uri) (decode-qname method env t) @@ -993,9 +992,9 @@ (if (plusp (length uri)) nil (cond - ((equalp method "HTML") :html) - ((equalp method "TEXT") :text) - ((equalp method "XML") :xml) + ((equalp local-name "HTML") :html) + ((equalp local-name "TEXT") :text) + ((equalp local-name "XML") :xml) (t (xslt-error "invalid output method: ~A" method))))))) (when indent @@ -1015,7 +1014,9 @@ (output-cdata-section-matchers spec)))) (when standalone (setf (output-standalone-p spec) - (boolean-or-error standalone))))))) + (boolean-or-error standalone))) + (when media-type + (setf (output-media-type spec) media-type)))))) (defun make-empty-declaration-array () (make-array 1 :fill-pointer 0 :adjustable t)) @@ -1681,6 +1682,7 @@ :hax-target (make-instance 'chtml::sink :ystream ystream) :sax-target sax-target + :media-type (output-media-type output-spec) :encoding sink-encoding))) (let ((method-key (output-method output-spec))) (cond -- 2.11.4.GIT