preparation for namespaces
Namespaces are one of the dark corners of the XML technologies. For SXML to XML conversion, I've investigated technical details on the namespace presentation in libxml2 and SXML. It seems that I'm not going to support all SXML features, and conversion will be a bit cheaty.
Namespaces in libxml2 is quite a simple thing, and it is documented.
There are several pre-docs on namespaces in SXML, with opinions:
But the main source of information is the SXML specification. I'm not going to cite it. Instead, I'm going to demonstrate options on a simple example. The document:
It seems (I can't check at the moment) that SSAX parser should produce:
Although such names ("a:b:c:d:doc") make no problem to Scheme, they are not so good for human beings. So it is posible to define a map from IDs to URIs and force parser to return namespace IDs instead of URIs. For example, having ID "w" for URI "a:b:c:d", result is:
(w:doc (@ (@ w "a:b:c:d")) "data")
It's much better, but it's not good for reverse transformation because original prefix is lost. So there is a format to save the original prefix:
(w:doc (@ (@ w "a:b:c:d") z) "data")
Now it's time to think about algorithm for SXML to libxml2 transformation.