bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#20339: sxml simple: sxml->xml mishandles namespaces?


From: tomas
Subject: bug#20339: sxml simple: sxml->xml mishandles namespaces?
Date: Sat, 25 Apr 2015 22:25:09 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

-----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] <http://okmij.org/ftp/papers/SXML-paper.pdf>

- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlU7+CUACgkQBcgs9XrR2kaSxACfdljxbGyVNILgombB3jYWjeOq
1zwAn2RzIEHcJbJIlIMRkaEAIjNFcH7M
=MSYu
-----END PGP SIGNATURE-----





reply via email to

[Prev in Thread] Current Thread [Next in Thread]