From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: tomas@tuxteam.de Newsgroups: gmane.lisp.guile.bugs Subject: bug#20339: sxml simple: sxml->xml mishandles namespaces? Date: Tue, 21 Apr 2015 11:44:38 +0200 Message-ID: <20150421094438.GA22715@tuxteam.de> References: <20150415194714.GA30295@tuxteam.de> <87oamh25sc.fsf@mango.localdomain> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; x-action=pgp-signed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1429609583 9152 80.91.229.3 (21 Apr 2015 09:46:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 21 Apr 2015 09:46:23 +0000 (UTC) Cc: 20339@debbugs.gnu.org To: Ricardo Wurmus Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Tue Apr 21 11:46:14 2015 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YkUkt-0002Po-So for guile-bugs@m.gmane.org; Tue, 21 Apr 2015 11:46:12 +0200 Original-Received: from localhost ([::1]:57222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YkUkt-0006IL-CL for guile-bugs@m.gmane.org; Tue, 21 Apr 2015 05:46:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YkUkp-0006I6-01 for bug-guile@gnu.org; Tue, 21 Apr 2015 05:46:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YkUkk-0000Te-Ln for bug-guile@gnu.org; Tue, 21 Apr 2015 05:46:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44495) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YkUkk-0000TY-GA for bug-guile@gnu.org; Tue, 21 Apr 2015 05:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YkUkk-0007Xu-9o for bug-guile@gnu.org; Tue, 21 Apr 2015 05:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: tomas@tuxteam.de Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 21 Apr 2015 09:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20339 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 20339-submit@debbugs.gnu.org id=B20339.142960952028915 (code B ref 20339); Tue, 21 Apr 2015 09:46:02 +0000 Original-Received: (at 20339) by debbugs.gnu.org; 21 Apr 2015 09:45:20 +0000 Original-Received: from localhost ([127.0.0.1]:34266 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YkUk3-0007WF-Ts for submit@debbugs.gnu.org; Tue, 21 Apr 2015 05:45:20 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]:54735 helo=tomasium.tuxteam.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YkUjQ-0007Uo-TH for 20339@debbugs.gnu.org; Tue, 21 Apr 2015 05:44:41 -0400 Original-Received: from tomas by tomasium.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1YkUjO-000623-OP; Tue, 21 Apr 2015 11:44:38 +0200 In-Reply-To: <87oamh25sc.fsf@mango.localdomain> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7773 Archived-At: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tue, Apr 21, 2015 at 11:24:03AM +0200, Ricardo Wurmus wrote: > Hi Tomás, > > tomas@tuxteam.de writes: > > > When transforming SXML to XML, namespaces don't seem to be handled > > properly: > > > [...] > > > > The problem is that SXML used the concatenated (full) namespace with the > > name as tag (and attribute) names for namespaced items. When serializing > > to XML it should try to find abbreviations for those namespaces and issue > > the corresponding namespace declarations. > > > > Instead, sxml->xml tries to split the (namespace:name) combination > > at the first colon and to check the name -- and fails miserably at > > (namespace:name) combinations à la "http://www.w3.org/1999/xlink:href" > > (procedure check-name). Since there are two colons, the name part > > has now a colon. > > xml->sxml has an optional #:namespaces argument, where you can pass an > alist of keys to URLs to be used in the sxml output: Aha. Didn't know about this one, thanks. Yes, the problem is that SXML loses the link to the "real" namespaces: the application around it has to keep track of that. > Passing this to sxml->xml yields: > > > width="20" > stroke-width="2" > stroke="purple" > id="rect1" > height="20" > fill="yellow" /> > y="5" x="30" > width="20" > stroke-width="2" > stroke="purple" > ry="5" rx="8" > height="20" > fill="blue" /> > Yes, this looks "nearly" right, except... > Unfortunately, sxml->xml will not replace the namespace abbreviations, > nor will it add appropriate xmlns attributes, so "svg" and "xlink" are > devoid of any meaning. exactly. > Since xml->sxml accepts a namespace alist I suppose it would make sense > to extend sxml->xml to do the same. This is more or less what I do in my proposed patch (it's in the bugs mailing list as 20339@debbugs.gnu.org). It passes around an alist of (namespace . abbrev) associations (it's inverted wrt #:namespaces in xml->sxml). Only that the abbreviations are "generated" as ns1, ns2 and so on (and the namespace declarations are woven into the attributes list). So far not reply to my bug report, but this gives me the chance to bikeshed my patch to death :-P Thanks for looking into that -- and for prodding me into looking at more sources :) Regards - -- t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlU2HAYACgkQBcgs9XrR2kYq+gCfexhJ5qFyN4QmIf4TfddPqyfT 434An3BSVKtyovRJdg8MGHzAY8I0/NTD =O9Kj -----END PGP SIGNATURE-----