
Hello, My document uses xi:include to include another XML document, and by default this adds an xml:base="common.xml" to the included node(s). Using xmllint --xinclude --nofixup-base-uris document.xml I can avoid adding xml:base. How can I achieve the same with lxml? I.e. how do I avoid the base? It seems that setting _Element.base to None is a poor, even unstable solution. Thanks! Jens -- Jens Tröger http://savage.light-speed.de/

Hi again, I guess until I figure out if there is a clean way of fixing up the xml:base attribute, I shall stick with this uncomfortable hack: root = docxml.getroottree() root.xinclude() for e in root.xpath(".//*"): e.base = None del e.attrib["{http://www.w3.org/XML/1998/namespace}base"] This seems to work for my scenario... Jens On Sat, Jun 04, 2016 at 08:27:36AM +0200, Jens Tröger wrote:
-- Jens Tröger http://savage.light-speed.de/

Jens Tröger schrieb am 04.06.2016 um 17:40:
This sets the option "XML_PARSE_NOBASEFIX" in the parser, which is not currently used by lxml. I would consider a pull request that adds a parser option for it.
You shouldn't need to set "e.base", just delete the attributes. But if you really want to get rid of the xml:base attributes, then this is a way to do it. Note that something like root.iter(etree.Element) is faster and more efficient than your XPath query above. Stefan

Hi again, I guess until I figure out if there is a clean way of fixing up the xml:base attribute, I shall stick with this uncomfortable hack: root = docxml.getroottree() root.xinclude() for e in root.xpath(".//*"): e.base = None del e.attrib["{http://www.w3.org/XML/1998/namespace}base"] This seems to work for my scenario... Jens On Sat, Jun 04, 2016 at 08:27:36AM +0200, Jens Tröger wrote:
-- Jens Tröger http://savage.light-speed.de/

Jens Tröger schrieb am 04.06.2016 um 17:40:
This sets the option "XML_PARSE_NOBASEFIX" in the parser, which is not currently used by lxml. I would consider a pull request that adds a parser option for it.
You shouldn't need to set "e.base", just delete the attributes. But if you really want to get rid of the xml:base attributes, then this is a way to do it. Note that something like root.iter(etree.Element) is faster and more efficient than your XPath query above. Stefan
participants (2)
-
Jens Tröger
-
Stefan Behnel