namespaces are completed at the first look, but then not

Yesterday I succeeded in writing a code for processing an auxiliary SXML list and reporting namespace definition pairs (prefix and URI). I thought I was still too far from finalizing namespaces, but today I've just finished it in less than half on hour. Unfortunately, the code has a bug.

Here is a small example of namespace conversion. SXML:

(e1 (@
    (ns:a1 "a1")
    (@ (*NAMESPACES* (ns "myns"))))
  (e2 (@
      (ns:a2 "a2")))))

XML:

<e1 xmlns:ns="myns" ns:a1="a1">
  <e2 ns:a2="a2"/>
</e1>

I decided to provide a similar example and found a bug. At the moment of writing, SXML

(e1 (@
    (ns:a1 "a1")
    (@ (*NAMESPACES* (ns "myns"))))
  (e2 (@
      (ns:a2 "a2")
      (@ (*NAMESPACES* (ns "yourns")))))))

is resulting in

<e1 xmlns:ns="yourns" ns:a1="a1">
  <e2 xmlns:ns="yourns" ns:a2="a2"/>
</e1>

The bug is that "xmlns:ns" at "e1" should be "myns", not "yours". The first attempt on fixing is failed, giving up.

And I should also test default namespace.

Categories: Generative XML

Updated: