Hi: using lxml 3.3.5 our project is implementing XML catalogs.
On initial testing it appears that the XML_CATALOG_FILES environment
variable needs to be set before lxml is imported, i.e.:
# e.g. 1: works
import os
os.environ['XML_CATALOG_FILES'] = '/tmp/catalog.xml'
from lxml import etree
...
# validate XML
schema = etree.XMLSchema(file=myschema)
parser = etree.XMLParser(schema=schema)
doc = etree.fromstring(postdata, parser)
# e.g. 2: does not work
import os
from lxml import etree
...
os.…
[View More]environ['XML_CATALOG_FILES'] = '/tmp/catalog.xml'
...
# validate XML
schema = etree.XMLSchema(file=myschema)
parser = etree.XMLParser(schema=schema)
doc = etree.fromstring(postdata, parser)
Is there any way for lxml to realize XML_CATALOG_FILES after being imported?
Thanks
..Tom
[View Less]
Having an issue with an xml file that has a namespace, but no prefix. The result of getpath() is showing as '*'Is there a workaround? I must be missing something very basic, but the documentation for getpath() doesn't mention what need to be done in this case (http://lxml.de/xpathxslt.html#generating-xpath-expressions)
##getpath.pyfrom lxml import etreeimport sys
xml_file = sys.argv[1]parser = etree.XMLParser(remove_blank_text=True)tree = etree.parse(xml_file, parser)root = tree.getroot(…
[View More])
for child in root.iter(): print(tree.getpath(child))
##test1.xml -- with xmlns, but no prefix -- the result is not what I'm expecting<Test xmlns="http://www.test.org/test"> <elem>some text</elem></Test>
$ python getpath.py test1.xml/*/*/*
##test2.xml -- without xmlns -- showing the expected results<Test> <elem>some text</elem></Test>
$ python getpath.py test2.xml/Test/Test/elem
##test3.xml -- xmlns with prefix -- working as expected<ns:Test xmlns:ns="http://www.test.org/test"> <ns:elem>some text</ns:elem></ns:Test>
$ python getpath.py test3.xml /ns:Test/ns:Test/ns:elem
Cheers,Aaron
[View Less]