Commit d055086f authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

rewrite xml_to_text transform using lxml, so as to support other encoding than utf-8.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39077 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d7f7f484
from Products.PortalTransforms.libtransforms.retransform import retransform
from Products.PortalTransforms.interfaces import itransform
from zope.interface import implements
from lxml import etree
class xml_to_text(retransform):
class xml_to_text:
implements(itransform)
__name__ = 'xml_to_text'
inputs = ('text/xml', 'application/xml')
output = 'text/plain'
def name(self):
return self.__name__
def convert(self, data, cache, **kw):
out = ''.join(etree.fromstring(data).itertext()).encode('utf-8')
cache.setData(out)
return cache
def register():
return xml_to_text("xml_to_text",
('<[^>]*>', ' '),
)
return xml_to_text()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment