1) ... but I want to check that I did't forget to use the map in the reverse (SXML to XML) conversion.
No, I didn't forget.
3) The real bug is coredumping on a certain construction. I stopped programming when I got coredump and can't say for sure, but I think I know the reason and solution in advance.
The idea was wrong, but not very much wrong.
It was easy to make a test case:
<s:scheme> (define x (x:current-node)) x </s:scheme>
I even did not debug this case. The problem is obvious. I'm inserting a subtree to the output document by reference. So I have the same subtree in the different trees. This is not supported by libxml2, it segfaults somewhere, probably when freeing the same block of memory once again.
After thinking some time I realized that code mustn't insert node by reference and there were only two solutions:
* skip a node which is in the map,
* make a copy of the node and add the copy.
I decided to follow the second way. I can't explain why, but it seems more reasonable for me.
By the way, code prints a warning message:
scm_to_node: bounded node can't be added to tree, adding a free copy