first attempt on namespaces conversion

The code splits an element's full name on two parts, looks up in the tree for ns prefix or ns URI and creates a ns definition if not found. There is also a draft code to check that ns definitions are complete.

I specified the algorithm of conversion in previous entries, but the simplest example have revealed two weak points.

Error 1.

SXML: ... (a:b:c:d:doc "data") ...
XML: <x><a:b:c:d:doc>data</a:b:c:d:doc></x>

There is no namespace definition in the result and no any warning on the console. The error is that I check for ns completeness on returning from the attributes processing. In this case I have no attributes at all, and so have got no any warning.

Error 2.

The fake attributes set is added.

SXML: ... (a:b:c:d:doc (@) "data") ...
XML: <x xmlns:a:b:c:d=""><a:b:c:d:doc>data</a:b:c:d:doc></x>

The "xmlns" is attached to "x", not to "a:b:c:d". The reason is that ns definition can be created only together with attaching it to some node. I attach it to a context node, and at the moment when I'm going to create "doc", the context node is "x.

The funny thing is that "xmlNewNode" expects an already created ns definition, and "xmlNewNs" expects an already created node. Just a sort of circular reference. Fortunately, it seems that this loop can be broken by using "xmlSetNs" a posteriori. Will see later.

Categories: Generative XML

Updated: