namespaces are finished
Namespace support in the SXML to libxml2 conversion is completed.
I though I could finish namespace conversion much earlier. But programming was not very easy because I was finding more and more features. Some time ago I decided that I had done everything, but default namespaces forced new changes.
The first thing in finalization was to support the original namespace prefixes. Consider the example of SXML:
(a:b:c:d:doc (@ (@ (*NAMESPACES* (a:b:c:d "http://localhost/z" oldns)))) "data" (a:b:c:d:subdoc))
Earlier it was producing the following XML:
<a:b:c:d:doc xmlns:a:b:c:d="http://localhost/z"> data <a:b:c:d:subdoc> </a:b:c:d:doc>
Now the correct translation is:
<oldns:doc xmlns:oldns="http://localhost/z"> data <oldns:subdoc> </oldns:doc>
Originally I thought I never need the original prefix functionality, but finally I realized that it is the only way to define default namespaces. The namespaced SXML names must have a colon in name, so they have a prefix, but the resulting XML shouldn't have a prefix. The rewriting is the only way to get rid of the prefix in the XML.
Note that we have to rewrite not to the empty string, but to the NULL value. No Scheme symbol corresponds to the NULL, so SXML uses a special name *DEFAULT* for NULL.
Suppose you have "*DEFAULT*" as the original prefix in the SXML example above. Then the result of translation is:
<doc xmlns="http://localhost/z"> data <subdoc> </doc>
Imprementation of the prefix rewriting was surprisingly simple.
While processing a namespace definition, we remember the original prefix in the "_private" field of the "xmlNs" structure.
I already had a code to post-process the namespace definitions on exiting from an element. I've added a checking for the "_private" field followed by rewriting.
I've added tests for namespace conversion. Among them are slightly modified examples from the SXML specification. All tests are succesfully passed.
And also I found a problem with xsltproc. More on it later.