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: Sat, 25 Apr 2015 22:25:09 +0200 Message-ID: <20150425202509.GA3544@tuxteam.de> References: <20150415194714.GA30295@tuxteam.de> <87oamh25sc.fsf@mango.localdomain> <20150421094438.GA22715@tuxteam.de> <87fv7s1bjn.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 1429993587 20049 80.91.229.3 (25 Apr 2015 20:26:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 25 Apr 2015 20:26:27 +0000 (UTC) Cc: 20339@debbugs.gnu.org To: Ricardo Wurmus Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sat Apr 25 22:26:16 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 1Ym6eV-0002C2-CS for guile-bugs@m.gmane.org; Sat, 25 Apr 2015 22:26:15 +0200 Original-Received: from localhost ([::1]:49279 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ym6eU-0007pG-Bk for guile-bugs@m.gmane.org; Sat, 25 Apr 2015 16:26:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ym6eQ-0007p8-GI for bug-guile@gnu.org; Sat, 25 Apr 2015 16:26:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ym6eL-0002CF-FV for bug-guile@gnu.org; Sat, 25 Apr 2015 16:26:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:50211) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ym6eL-0002Br-Bt for bug-guile@gnu.org; Sat, 25 Apr 2015 16:26:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Ym6eH-0002jF-RT for bug-guile@gnu.org; Sat, 25 Apr 2015 16:26: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: Sat, 25 Apr 2015 20:26:01 +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.142999351510435 (code B ref 20339); Sat, 25 Apr 2015 20:26:01 +0000 Original-Received: (at 20339) by debbugs.gnu.org; 25 Apr 2015 20:25:15 +0000 Original-Received: from localhost ([127.0.0.1]:39987 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ym6dW-0002iE-8w for submit@debbugs.gnu.org; Sat, 25 Apr 2015 16:25:14 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]:39513 helo=tomasium.tuxteam.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ym6dT-0002i3-If for 20339@debbugs.gnu.org; Sat, 25 Apr 2015 16:25:12 -0400 Original-Received: from tomas by tomasium.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1Ym6dR-0001BN-An; Sat, 25 Apr 2015 22:25:09 +0200 In-Reply-To: <87fv7s1bjn.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:7779 Archived-At: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wed, Apr 22, 2015 at 04:29:32PM +0200, Ricardo Wurmus wrote: > >> Since xml->sxml accepts a namespace alist I suppose it would make sense > >> to extend sxml->xml to do the same. > > Attached is a minimal patch to extend "sxml->xml" such that it accepts an > optional keyword argument "namespaces" with an alist of prefixes to > URLs, analogous to "xml->sxml". Thank you again for the patch. I applied it against 2.0.11, and can confirm that it works as advertised :-) I didn't see that xml->sxml has an optional parameter #:namespaces -- to be honest, I didn't expect it there. So if one knows beforehand what namespaces are used in the XML in question, it's possible to use the pair xml->sxml and xml->sxml this way (with your patch, of course, because otherwise sxml->xml "forgets" to output the relevant XML namespace declarations). Reading again Oleg Kiselyov's paper[1] I understand that SXML can, as does XML have namespace abbreviations (called there user-ns-shortcut). It's not exctly the same thing, but somehow isomorphic. One might use the XML's abbreviations in the SXML representation, of course. The problem with this approach is that you either have to carry the namespace associations "out-of-band", and that you have to know which namespaces to expect before parsing the XML. A (more cosmtic) problem is that all namespace declarations are "moved" to the top-level, because the SXML keeps no "memory" of which node the namespace declarations were attached to in the original XML. In [1], there is a mechanism for stashing namespace mappings in the "attributes list" (strictly in the annotations, which are optionally tacked to the tail of the attributes list, under the tag *NAMESPACES*. Anyway -- what would be a good way forward here? I could imagine taking note of the namespace abbreviations in the *NAMESPACES* list (while xml->sxml) and issuing the corresponding declarations in sxml->xml. Makes sense? Regards [1] - -- tomás -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlU7+CUACgkQBcgs9XrR2kaSxACfdljxbGyVNILgombB3jYWjeOq 1zwAn2RzIEHcJbJIlIMRkaEAIjNFcH7M =MSYu -----END PGP SIGNATURE-----