lxml

Unable to use Diazo (plone.app.theming) on Centos

人盡茶涼 提交于 2019-12-01 21:06:49
问题 I made a webportal on my mac using plone4.1 and Diazo. Now, I'm trying to deploy it on my server (CentOs) where there is yet another site with plone4.0.5 + collectivexdv. When I run the site (in a brand new buildout) with my diazotheme I obtain this lines via shell (instance fg): 2011-09-27 09:32:10 ERROR plone.transformchain Unexpected error whilst trying to apply transform chain Traceback (most recent call last): File "/home/plone/.buildout/eggs/plone.transformchain-1.0-py2.6.egg/plone

lxml with schema 1.1

余生颓废 提交于 2019-12-01 20:55:41
I'm trying to use lxml with the xs:assert validation tag. I've tried using the example from this IBM page: http://www.ibm.com/developerworks/library/x-xml11pt2/ <xs:element name="dimension"> <xs:complexType> <xs:attribute name="height" type="xs:int"/> <xs:attribute name="width" type="xs:int"/> <xs:assert test="@height < @width"/> </xs:complexType> </xs:element> It seems like lxml doesn't support XML Schema 1.1. Can someone validate this? What XML (for Python) engine does support Schema 1.1? The two schema processors that currently support XSD 1.1 are Xerces and Saxon - both Java based. 来源:

Scrapy: Unable to create a project

我只是一个虾纸丫 提交于 2019-12-01 20:22:15
I had issues installing scrapy respect to lxml but then I found some information on stackoverflow. Based on that information I did a sudo easy_install lxml with some error I think scrapy got install: Reason I came to that judgement is that I repel I could do following: Python 2.7.5 (default, Jul 28 2013, 07:27:04) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from scrapy import * >>> But when I try to do the scrapy tutorial I get following error: $ scrapy startproject tutorial Traceback (most recent

How to remove all attributes from element

喜夏-厌秋 提交于 2019-12-01 19:40:46
How to remove all attributes of the specific elements througout the document. I'm trying something like this: from bs4 import UnicodeDammit from lxml import html content = open("source.html").read() document = UnicodeDammit(content, is_html=True) parser = html.HTMLParser(encoding=document.original_encoding) root = html.document_fromstring(content, parser=parser) for attr in root.xpath('.//table/@*'): del attr.attrib Here I'm trying to delete all attributes from all tables in the document using xpath, but it doesn't work. This is one possible way, assuming that you want to remove all attributes

lxml html5parser ignores “namespaceHTMLElements=False” option

你说的曾经没有我的故事 提交于 2019-12-01 19:38:38
The lxml html5parser seems to ignore any namespaceHTMLElements=False option I pass to it. It puts all elements I give it into the HTML namespace instead of the (expected) void namespace. Here’s a simple case that reproduces the problem: echo "<p>" | python -c "from sys import stdin; \ from lxml.html import html5parser as h5, tostring; \ print tostring(h5.parse(stdin, h5.HTMLParser(namespaceHTMLElements=False)))" The output from that is this: <html:html xmlns:html="http://www.w3.org/1999/xhtml"><html:head></html:head><html:body><html:p> </html:p></html:body></html:html> As can be seen, the html

How to remove all attributes from element

非 Y 不嫁゛ 提交于 2019-12-01 19:36:15
问题 How to remove all attributes of the specific elements througout the document. I'm trying something like this: from bs4 import UnicodeDammit from lxml import html content = open("source.html").read() document = UnicodeDammit(content, is_html=True) parser = html.HTMLParser(encoding=document.original_encoding) root = html.document_fromstring(content, parser=parser) for attr in root.xpath('.//table/@*'): del attr.attrib Here I'm trying to delete all attributes from all tables in the document

Unable to use Diazo (plone.app.theming) on Centos

点点圈 提交于 2019-12-01 19:35:55
I made a webportal on my mac using plone4.1 and Diazo. Now, I'm trying to deploy it on my server (CentOs) where there is yet another site with plone4.0.5 + collectivexdv. When I run the site (in a brand new buildout) with my diazotheme I obtain this lines via shell (instance fg): 2011-09-27 09:32:10 ERROR plone.transformchain Unexpected error whilst trying to apply transform chain Traceback (most recent call last): File "/home/plone/.buildout/eggs/plone.transformchain-1.0-py2.6.egg/plone/transformchain/transformer.py", line 42, in __call__ newResult = handler.transformIterable(result, encoding

ImportError: No module named lxml.etree

落花浮王杯 提交于 2019-12-01 17:52:50
I'm trying to import premailer in my project, but it keeps failing at the etree import. I installed the 2.7 binary for lxml. The lxml module imports fine, and it's showing the correct path to the library folder if I log the lxml module, but I can't import etree from it. There's an etree.pyd in the lxml folder but python can't seem to see\read it. I'm on windows7 64bit. Does anyone know what's going wrong here? Samer Makary Try adding the library to the GAE .yaml file. Under libraries add -name: lxml version: latest Try to using etree without import it like (lxml.etree() ) I think it function

LXML and XSL document() Function

百般思念 提交于 2019-12-01 17:28:47
Hi i got the following files : merge.py: from lxml import etree xml_input = etree.XML(open('a.xml', 'r').read()) xslt_root = etree.XML(open('merge.xsl', 'r').read()) transform = etree.XSLT(xslt_root) print str(transform(xml_input)) merge.xsl: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <merge> <xsl:copy-of select="."/> <xsl:copy-of select="document('b.xml')"/> </merge> </xsl:template> a.xml: <?xml version="1.0" encoding="ISO-8859-1"?> <a> <test id="1"/> </a> b.xml: <?xml version="1.0" encoding="ISO-8859-1"?> <b> <test id="2"/> </b>

LXML and XSL document() Function

匆匆过客 提交于 2019-12-01 16:53:58
问题 Hi i got the following files : merge.py: from lxml import etree xml_input = etree.XML(open('a.xml', 'r').read()) xslt_root = etree.XML(open('merge.xsl', 'r').read()) transform = etree.XSLT(xslt_root) print str(transform(xml_input)) merge.xsl: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <merge> <xsl:copy-of select="."/> <xsl:copy-of select="document('b.xml')"/> </merge> </xsl:template> a.xml: <?xml version="1.0" encoding="ISO-8859-1"