Patch attached, it was created as mentioned at
http://www.gnu.org/software/guile/contribute/. Patch applicable to
guile versions 2.0.13 and 2.1.6 as the file simple.scm is identical in
both.

Let me know if any modifications are required.

Regards
sidhu1f
From 9b4e2448a4189a926bafb400b21d091fd07975be Mon Sep 17 00:00:00 2001
From: sidhu1f <sidh...@gmail.com>
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)
+  (display 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

On Fri, 20 Jan 2017 03:07:20 +0530,
amirou...@hypermove.net wrote:
> 
> Yes please share the patch
> 
> À jeu. janv. 19 20:27:35 2017 GMT+0100, sidhu1f a écrit :
> > 
> > On Wed, 18 Jan 2017 16:12:21 +0530,
> > sidhu1f wrote:
> > > Tried converting SXML to XML using sxml->xml function in (sxml simple)
> > > module, but it cannot handle SXML '*COMMENT*' construct, among others.
> > > Didn't find a conversion function in (saxml ssax) either.
> > > 
> > > Is there an established way to convert SXML to XML? Else, is there an
> > > effort to develop a convertor (ideally, ssax based) that one could
> > > contribute to?
> > 
> > Solved my own problem. Only a minor modification to the (sxml simple)
> > module is required to cleanly support the conversion of comments in
> > SXML notation to XML.
> > 
> > If anyone is interested, I'll be happy to share the patch.
> > 
> > Regards
> > sidhu1f
> > 
> >
> 
> -- 
> Sans sens apparats à apparaitre aux aprés de celle/ceux qui revaient d'une 
> enigme.

Reply via email to