* Converting SXML to XML
@ 2017-01-18 10:42 sidhu1f
2017-01-19 19:27 ` sidhu1f
0 siblings, 1 reply; 4+ messages in thread
From: sidhu1f @ 2017-01-18 10:42 UTC (permalink / raw)
To: Guile user
Greetings
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?
Regards
sidhu1f
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Converting SXML to XML
2017-01-18 10:42 Converting SXML to XML sidhu1f
@ 2017-01-19 19:27 ` sidhu1f
2017-01-19 21:37 ` amirouche
0 siblings, 1 reply; 4+ messages in thread
From: sidhu1f @ 2017-01-19 19:27 UTC (permalink / raw)
To: Guile user
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Converting SXML to XML
2017-01-19 19:27 ` sidhu1f
@ 2017-01-19 21:37 ` amirouche
2017-01-21 9:56 ` sidhu1f
0 siblings, 1 reply; 4+ messages in thread
From: amirouche @ 2017-01-19 21:37 UTC (permalink / raw)
To: sidhu1f; +Cc: guile-user
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Converting SXML to XML
2017-01-19 21:37 ` amirouche
@ 2017-01-21 9:56 ` sidhu1f
0 siblings, 0 replies; 4+ messages in thread
From: sidhu1f @ 2017-01-21 9:56 UTC (permalink / raw)
To: guile-user
[-- 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.
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-01-21 9:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).