“x:eval”, “x:deep-copy”, “current()”, and attributes

Namespaces are still working, xml node of the type “document” is now handled correctly, XSLT XPath functions are activated. To finish with the libxml to sxml conversion, support of the top-level attribute nodes and result tree fragments should be added.

Today’s development is a mess of small changes.

First of all, the Scheme function “x:value-of” is renamed to “x:eval”. It’s much more correct, as the name “value-of” implies that we convert a result to a string, and it’s not what we are doing.

Next, the Scheme function “x:deep-copy” is introduced. It makes copies of the sxml expressions. This code:

<x:scheme>
 (x:current)
</x:scheme>

produces warning

scm_to_node: bounded node can't be added to tree, adding a free copy

(see the explanation), and this code

<x:scheme>
 (x:deep-copy (x:current))
</x:scheme>

doesn’t.

Another issue solved is the XSLT functions in XPath. I’ve found how to allow using them, and added more test cases. Some new tests make sure that relative XPaths work properly, and the constructions “current()”, “self::node()” and “.” give the expected result.

Thanks to the improvement, I’ve finally tested conversion of the result of the XLT function “document()”. And it was useful, as the bug was found. The code

<a>
 <x:scheme>
  (x:eval "document('test.xml')")
 </x:scheme>
</a>

was producing

<a>
 <?xml version="1.0"?>
 <test>test.xml</test>
</a>

Xml declaration is redundant in the result. The problem is fixed now.

After getting the problem with the document nodes, I decided to check other top-level nodes. The only types to check are the attributes and the result tree fragments.

I’ve got a coredump on the attributes and decided to give up for today.

Leave a Reply