Am Mi 21 Mai 2014 15:36:12 CEST schrieb Stefan Behnel:
> Elwert, 21.05.2014 15:18:
>> I have a quite basic issue with loading entity definitions from a DTD
>> that I can’t wrap my head around:
>>
>> I have an XML file that declares its DTD:
>>
>> <?xml version="1.0" encoding="ISO-8859-1"?>
>> <!DOCTYPE StupidXML SYSTEM "bwl.dtd" []>
>> <StupidXML>
>> <bwlengl wcn="1" elabel="vulture; bird (gen.)"></bwlengl>
>> ...
>>
>> In that DTD, a couple of entities are declared. It is in the same
>> directory as the XML file.
>>
>> Now I try to parse the XML file:
>>
>> etree.parse('BWL.xml', parser=etree.XMLParser(load_dtd=True))
>>
>> Now this works if my current working directory is the one where the XML
>> file and DTD are located. This fails with an XMLSyntaxError (Entity not
>> defined) when my current working directory is somewhere else.
>>
>> Now I thought that the path to the DTD should be interpreted as being
>> relative to the location of the XML file, not relative to Python’s
>> working directory. Am I wrong? How would I preferably solve this?
>
> Did you try passing the absolute path to the XML file into parse()?

Yes, that was how I initially did it, but that also failed.

Regards,
Frederik


> Stefan
>
> _________________________________________________________________
> Mailing list for the lxml Python XML toolkit - http://lxml.de/
> lxml@lxml.de
> https://mailman-mail5.webfaction.com/listinfo/lxml