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:

* http://pair.com/lisovsky/xml/ns/
* http://sourceforge.net/mailarchive/forum.php?thread_id=759249&forum_id=599
* http://sourceforge.net/mailarchive/forum.php?thread_id=789156&forum_id=599

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:

<z:doc xmlns:z="a:b:c:d">data</z:doc>

It seems (I can't check at the moment) that SSAX parser should produce:

(a:b:c:d:doc "data")

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.

Categories: Generative XML

Updated: