unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: tomas@tuxteam.de
Cc: 20339@debbugs.gnu.org
Subject: bug#20339: sxml simple: sxml->xml mishandles namespaces?
Date: Tue, 12 Feb 2019 21:30:04 +0100	[thread overview]
Message-ID: <87wom4iwc3.fsf@elephly.net> (raw)
In-Reply-To: <20190212095602.GD13448@tuxteam.de>


tomas@tuxteam.de writes:

> As John has noted, the namespace mappings (i.e. the prefix -> namespace
> URI binding) are kind of lexically scoped (I'd call it subtree scoped,
> but structurally it is the same). While parsing is "easy" (assuming
> well-formed XML), serializing is not unambiguous.

The “fup” handler of the parser visits every element and has a list of
namespaces that are in scope at this point.  Its purpose is to return
the SXML representation of that element.  At this point we can record
the namespaces as attributes.  (That’s what the patch does.)

When baking XML from SXML we don’t need to do anything special — we only
need to convert everything to text, including the recorded namespace
attributes.  This isn’t pretty SXML (nor is it pretty XML), but it
appears to be correct as none of the namespace information is lost.

To get a better serialized representation the parser needs to do a
better job of identifying “new” namespaces.

> In a way, the library might want to be prepared to take hints from the
> application (as far as the XML is to be read by humans, there might be
> "better" and "worse" serializations).

The XML produced when this patch is applied will not be pretty.  To
generate minimal/pretty XML knowledge of the parent elements’ namespaces
is required — knowledge that the parser’s “fup” handler does not have.

We could try to alter the parser so that it not only passes the list of
namespaces that are currently in scope, but also a list of namespaces
that are in scope for the parent node.  This would allow us to determine
the list of *new* namespaces that absolutely must be declared for the
current node.  If there are no new namespaces we can simply ignore them
and produce minimal SXML (and thus minimal XML later when the SXML is
serialized).

--
Ricardo






  reply	other threads:[~2019-02-12 20:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-15 19:47 bug#20339: sxml simple: sxml->xml mishandles namespaces? tomas
2015-04-20  7:45 ` bug#20339: [PATCH] sxml->xml and namespaces: updated patch tomas
2015-04-21  9:24 ` bug#20339: sxml simple: sxml->xml mishandles namespaces? Ricardo Wurmus
2015-04-21  9:44   ` tomas
2015-04-22 14:29     ` Ricardo Wurmus
2015-04-23  6:57       ` tomas
2015-04-23  7:04         ` Ricardo Wurmus
2015-04-23  7:40           ` tomas
2015-04-25 20:25       ` tomas
2015-04-26 10:28         ` tomas
2016-06-23 19:32 ` Andy Wingo
2016-07-13 13:24   ` tomas
2016-07-13 18:08     ` tomas
2016-07-14 10:10     ` Andy Wingo
2016-07-14 10:26       ` tomas
2019-02-04 20:44       ` Ricardo Wurmus
2019-02-04 22:55         ` John Cowan
2019-02-05  9:12           ` Ricardo Wurmus
2019-02-05 12:57             ` Ricardo Wurmus
2019-04-08 12:14               ` tomas
2019-02-12  9:56         ` tomas
2019-02-12 20:30           ` Ricardo Wurmus [this message]
2019-05-03 10:46             ` bug#20339: Taking a step back (was: sxml simple: sxml->xml mishandles namespaces?) tomas

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=87wom4iwc3.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=20339@debbugs.gnu.org \
    --cc=tomas@tuxteam.de \
    /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).