Re: [lxml] bidirectional python <-> xml transformations?

Hopefully this will help. Note the callback occurs about halfway up the stack. Traceback (most recent call last): File "index.py", line 107, in <module> rslt_tree = trans(in_tree, mobile="'" + mobile_str + "'") File "xslt.pxi", line 582, in lxml.etree.XSLT.__call__ (src/lxml/lxml.etree.c:139795) File "lxml.etree.pyx", line 294, in lxml.etree._ExceptionContext._raise_if_stored (src/lxml/lxml.etree.c:9359) File "xsltext.pxi", line 195, in lxml.etree._callExtensionElement (src/lxml/lxml.etree.c:144738) File "index.py", line 100, in execute output_parent.append(results) File "readonlytree.pxi", line 475, in lxml.etree._AppendOnlyElementProxy.append (src/lxml/lxml.etree.c:69888) File "readonlytree.pxi", line 481, in lxml.etree._AppendOnlyElementProxy.append (src/lxml/lxml.etree.c:69807) File "readonlytree.pxi", line 534, in lxml.etree._roNodeOf (src/lxml/lxml.etree.c:70448) TypeError: invalid argument type <type 'list'> On 05/06/2013 04:01 PM, Simon Sapin wrote:

Le 06/05/2013 22:07, Eric Levy a écrit :
It seems this is the same issue as before: apply_templates() returns a list of results; element objects behave kind of like a list of their children and the .append() method expects a child element object rather than a list. Try one of these, depending on what you mean: output_parent.append(results[0]) output_parent.extend(results) (append takes one item to add, the list grows by one; extend takes an iterable of items, the list grows by the length of the iterable.) -- Simon Sapin
participants (2)
-
Eric Levy
-
Simon Sapin