From: sidhu1f <sidhu1f@gmail.com>
To: guile-user@gnu.org
Subject: Re: Converting SXML to XML
Date: Sat, 21 Jan 2017 15:26:20 +0530 [thread overview]
Message-ID: <5883304d.8b95620a.27d77.422e@mx.google.com> (raw)
In-Reply-To: <a830il.ok1qqv.2wsjbw-qmf@relay3-d.mail.gandi.net>
[-- Attachment #1: Type: text/plain, Size: 257 bytes --]
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
[-- Attachment #2: sxml-comment-support.patch --]
[-- Type: text/plain, Size: 1511 bytes --]
From 9b4e2448a4189a926bafb400b21d091fd07975be Mon Sep 17 00:00:00 2001
From: sidhu1f <sidhu1f@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
[-- Attachment #3: Type: text/plain, Size: 1030 bytes --]
On Fri, 20 Jan 2017 03:07:20 +0530,
amirouche@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.
prev parent reply other threads:[~2017-01-21 9:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-18 10:42 Converting SXML to XML sidhu1f
2017-01-19 19:27 ` sidhu1f
2017-01-19 21:37 ` amirouche
2017-01-21 9:56 ` sidhu1f [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5883304d.8b95620a.27d77.422e@mx.google.com \
--to=sidhu1f@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).