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

From: John Cowan <[email-masked]>
Date: Mon, 4 Feb 2019 17:55:14 -0500

On Mon, Feb 4, 2019 at 3:45 PM Ricardo Wurmus <[email-masked]> wrote:

\I changed name->sxml to use only the namespace aliases / abbreviations
> instead of the namespace URIs.

The trouble with that is that XML rnamespaces are lexically scoped, like
Scheme
local variables.  It is perfectly valid to map a prefix to more than one
URL,
as long as the namespace declarations are in either disjoint or nested
elements.  So you don't know what the absolute name of the element
or attribute is from just the prefix and the local part.

Furthermore, it is also legal to define more than one prefix for
the same URL, in which case names using either prefix are normally
treated as equivalent (however, you can't have elements like
<a:foo>...</b:foo>
even if a and b map to the same namespace).

* Is the value for “namespaces” that’s passed in to the
>   FINISH-ELEMENT procedure always the same?
>
> * Will the second return value of the final call to FINISH-ELEMENT
>   really always be the complete list of *all* namespaces that have been
>   encountered?
>

Definitely not, only the namespaces that are currently in scope.

* Are there valid XML documents for which the match patterns to inject
>   namespace declarations would not apply?  (e.g. documents with a PI
>   element and two separate XML trees)
>

That's not well-formed: you can only have a single element tree per XML
document, although you can have any number of PIs, comments, and
whitespace (which is normally ignored) before and after.

-- 
John Cowan          http://vrici.lojban.org/~cowan        [email-masked]
If I have seen farther than others, it is because I was looking through a
spyglass with my one good eye, with a parrot standing on my shoulder. --"Y"