From 9b4e2448a4189a926bafb400b21d091fd07975be Mon Sep 17 00:00:00 2001 From: sidhu1f Date: Sat, 21 Jan 2017 13:29:42 +0530 Subject: [PATCH] Add conversion of SXML comments to XML. * sxml/simple.scm: Add comment->xml. Augment sxml->xml to process comment construct similar to current processing of entity construct. --- module/sxml/simple.scm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/module/sxml/simple.scm b/module/sxml/simple.scm index 703ad9137..4378b69e6 100644 --- a/module/sxml/simple.scm +++ b/module/sxml/simple.scm @@ -311,6 +311,12 @@ port." (display str port) (display "?>" port)) +;; FIXME: ensure str is valid +(define (comment->xml str port) + (display "" port)) + (define* (sxml->xml tree #:optional (port (current-output-port))) "Serialize the sxml tree @var{tree} as XML. The output will be written to the current output port, unless the optional argument @var{port} is @@ -331,6 +337,10 @@ present." (if (and (list? (cdr tree)) (= (length (cdr tree)) 2)) (pi->xml (cadr tree) (caddr tree) port) (error "bad *PI* args" (cdr tree)))) + ((*COMMENT*) + (if (and (list? (cdr tree)) (= (length (cdr tree)) 1)) + (comment->xml (cadr tree) port) + (error "bad *COMMENT* args" (cdr tree)))) (else (let* ((elems (cdr tree)) (attrs (and (pair? elems) (pair? (car elems)) -- 2.11.0