RuntimeError executing stylesheet with Amara 2.0.0a6 on Python 2.7.5

12 views
Skip to first unread message

Chimezie Ogbuji

unread,
Aug 17, 2014, 9:56:43 PM8/17/14
to ak...@googlegroups.com
Hello.

I recently updated my Macbook pro to OSX 10.9.4 and had to reinstall all the components I use for an Akara / Amara / Akamu web application I deploy for medical information management.  In short, when I try to run the amara.xslt.transform method on the following XML source (gutted in order to try to isolate the problem):

<Root/>

I get the traceback at the bottom of the page.

The deployed, production web application does not reproduce this when I try to transform the exact same source document with the same XSLT source (which is attached to this email for reference):

>>> import amara
>>> amara.__version__
'2.0.0a6'
>>> from amara.xslt import transform
>>> transform('<Root/>','xslt/index.xslt')
'<html xmlns="http://www.w3.org/1999/xhtml”> .. etc.. </html>’

Of course, I haven’t reinstalled or upgraded any of the various software packages (including Amara) since the application was deployed earlier this year, hence my printing of the version number to make sure I wasn’t comparing apples to oranges.

Notably, the server is running Python 2.6.6, while I”m running Python 2.7.5 locally.  

Unfortunately, the traceback error is such that I don’t know where to begin troubleshooting (there are many xsl:if elements).  Is there a place in the stack where I could add print statements that might help me identify where the problem is in the stylesheet?

Thanks in advance!

——————— %<----------------

>>> import amara
>>> amara.__version__
'2.0.0a6'
>>> from amara.xslt import transform
>>> transform('<Root/>','xslt/index.xslt')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/amara/xslt/__init__.py", line 521, in transform
    return proc.run(inputsource(source), params, result)
  File "/Library/Python/2.7/site-packages/amara/xslt/processor.py", line 251, in run
    return self._run(document, parameters, result)
  File "/Library/Python/2.7/site-packages/amara/xslt/processor.py", line 547, in _run
    self.transform.apply_templates(context, [node])
  File "/Library/Python/2.7/site-packages/amara/xslt/tree/transform_element.py", line 666, in apply_templates
    template.instantiate(context, params)
  File "/Library/Python/2.7/site-packages/amara/xslt/tree/template_element.py", line 102, in instantiate
    child.instantiate(context)
  File "/Library/Python/2.7/site-packages/amara/xslt/tree/literal_element.py", line 67, in instantiate
    self.process_children(context)
  File "/Library/Python/2.7/site-packages/amara/xslt/tree/literal_element.py", line 67, in instantiate
    self.process_children(context)
  File "/Library/Python/2.7/site-packages/amara/xslt/tree/literal_element.py", line 67, in instantiate
    self.process_children(context)
  File "/Library/Python/2.7/site-packages/amara/xslt/tree/literal_element.py", line 67, in instantiate
    self.process_children(context)
  File "/Library/Python/2.7/site-packages/amara/xslt/tree/if_element.py", line 21, in instantiate
    if self._test.evaluate_as_boolean(context):
  File "/Library/Python/2.7/site-packages/amara/xpath/expressions/__init__.py", line 72, in evaluate_as_boolean
    docstring=unicode(self))
  File "/Library/Python/2.7/site-packages/amara/xpath/compiler/__init__.py", line 45, in compile
    firstlineno)
  File "/Library/Python/2.7/site-packages/amara/xpath/compiler/assembler.py", line 60, in assemble
    stacksize = self._compute_stack_size()
  File "/Library/Python/2.7/site-packages/amara/xpath/compiler/assembler.py", line 202, in _compute_stack_size
    return walk(self.entry, 0, 0)
  File "/Library/Python/2.7/site-packages/amara/xpath/compiler/assembler.py", line 192, in walk
    maxsize = walk(instr.target, size, maxsize)
  File "/Library/Python/2.7/site-packages/amara/xpath/compiler/assembler.py", line 198, in walk
    maxsize = walk(block.next, size, maxsize)
  File "/Library/Python/2.7/site-packages/amara/xpath/compiler/assembler.py", line 187, in walk
    raise RuntimeError("unhandled instruction: %r" % instr)
RuntimeError: unhandled instruction: <instr at 0x1082cd9a8: opname='<block 1, offset 0>', oparg=None, target=None>


-- 
Chimezie Ogbuji
Sent with Airmail
index.xslt

Uche Ogbuji

unread,
Aug 18, 2014, 12:34:30 AM8/18/14
to ak...@googlegroups.com
On Sun, Aug 17, 2014 at 7:56 PM, Chimezie Ogbuji <chim...@gmail.com> wrote:
Unfortunately, the traceback error is such that I don’t know where to begin troubleshooting (there are many xsl:if elements).  Is there a place in the stack where I could add print statements that might help me identify where the problem is in the stylesheet?

Hmm. I guess the best bet I can think of is to add a try/except around this key bit:


And in the exception handler print (str(self), repr(self)) to see the actual, problem XPath.

I know there are still rough edges left from Jeremy's redesign of Amara's XPath around Python's AST facilities, and unfortunately I have never had the time to dig into it all myself. For Amara3 my thoughts are to reimplement XPath by hand.


--
Uche Ogbuji                                       http://uche.ogbuji.net
Founding Partner, Zepheira                  http://zepheira.com
Author, _Ndewo, Colorado_                 http://uche.ogbuji.net/ndewo/
Founding editor, Kin Poetry Journal      http://wearekin.org
http://copia.ogbuji.net    http://www.linkedin.com/in/ucheogbuji    http://twitter.com/uogbuji

Luis Miguel Morillas

unread,
Aug 18, 2014, 5:42:44 PM8/18/14
to ak...@googlegroups.com
I reported similar error time ago [1] I had an issue with xpath rules
using *or* connectors such as:

u'//course[@year="2008" or @year="2010"]'


I'll try to test your example later.



[1] https://groups.google.com/forum/?hl=en&fromgroups=#!topic/akara-dev/Ksbou-n3lCY%5B1-25-false%5D



Best regards,

-- luismiguel (@lmorillas)
> --
> You received this message because you are subscribed to the Google Groups
> "akara" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akara+un...@googlegroups.com.
> To post to this group, send email to ak...@googlegroups.com.
> Visit this group at http://groups.google.com/group/akara.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages