Re: [MathDOM] Problem running MathDOM with latest lxml
Brought to you by:
scoder
From: Stefan B. <ste...@be...> - 2007-04-08 15:31:40
|
Hi, sorry for the late reply. chrystiano araujo wrote: > i've been using mathdom-0.7. > > there is a doubt. Could you help me, please?? > > In a Quick example: > >>>> from mathml.lmathdom import MathDOM > # use lxml implementation >>>> doc = MathDOM.fromString("+2^x+4*-5i/6", "infix_term") # > parse infix term >>>> [ n.value() for n in doc.xpath(u'//math:cn[@type="integer"]') ] # > find integers > x [2, 4, 6] >>>> for apply_tag in doc.xpath(u'//math:apply[math:plus]'): > # replace '+' with '-' > > ... apply_tag.set_operator(u'minus') tthis line, there is a error > Traceback (most recent call last): > File "<stdin>", line 2, in <module> > AttributeError: 'etree._Element' object has no attribute 'set_operator' I assume you are using a recent version of lxml? The way lxml sets up custom element classes (which are used by MathDOM to implement the MathML namespace) has changed in lxml 1.1. I'll fix MathDOM as soon as possible and release a 0.7.2, but it's not as simple as "change this 0 to 1 and it works". Please use lxml 1.0.x for now, which you can get here: http://codespeak.net/lxml/ Ready-to-install binaries are here: http://cheeseshop.python.org/pypi/lxml/1.0.4 http://cheeseshop.python.org/pypi/lxml/1.0.3 > if do you have any documentation of mathdom, send to me, please. Admittedly, MathDOM is pretty much underdocumented. However, it's not that hard to use, so you should get along once you've got it running. Take a look at the test scripts that come with the distribution. Regards, Stefan |