For further developments, I need some special properties of an XPath engine (maybe DDO SXPath). To be discussed during private meetings with developers.
I'd like to register functions to be used in XPath expressions. As ddo engine uses special optimization tricks, the functions should be restricted somehow.
Scheme functions should be written in such a way, that it is possible to transform them to get some properties. For example, if we know for sure that in some place a function gets node but not nodeset, it's better to use a specially generated version of the functions to work only with a node (so no type checks in the function and so speed optimization).
Another example is getting a child. If we know that there is only one "title", then we can stop at the first match and ignore the rest of the list of the children.
XPath can return attribute nodes or namespace declaration nodes. In SXML format, we can't distinguish between them and normal nodes. But we should be able to do it in order to implement an XSLT processor.
When we want to move a namespaced subtree from one document to another, we should be careful with namespaces. We should copy or create enough namespace declarations to have the subtree valid, and we shouldn't flood the subtree with redundant ns declarations. Smart support of ns requires auxiliary structures complementary to an SXML tree.
There are some special cases with namespaces. Prefix 'xml' is always defined, attribute "xmlns" is indeed namespaced. These details also should be taken into account.