[lxml-dev] Setting URL from lxml.html.fromstring, etc
Stefan Behnel
stefan_ml at behnel.de
Fri Feb 29 21:17:12 CET 2008
Hi,
Ian Bicking wrote:
> Stefan Behnel wrote:
>> Don't you think it should behave differently for XML and HTML? For
>> XML, I'd
>> expect it to depend on xml:base, while for HTML, it'd rather always
>> depend on
>> the document URL (and not set an xml:base attribute on assignment).
>
> Sure, they act somewhat differently, but does it make sense to use two
> different names? I think they mean similar things in both cases, though
> perhaps the per-element base attribute in HTML shouldn't be writable.
> (Though the tree is kind of this weird invisible thing that you wouldn't
> know is there except for things like docinfo.URL, but a little
> documentation can fix that of course.)
ok, I do prefer 'base' then, though, as it matches xml:base. It also makes
less sense in the HTML area than in the XML area, where you actually /have/
something like a base URL of an element, rather than just a URL of a document
that the Element happens to be in. So, if you move an HTML Element from one
tree to another, it will change its base URL, while in the XML world, you
/can/ work around that if you need/want to.
I think we should deprecate 'base_url' in favour of 'base', and document the
respective behaviour in the doc strings of both properties.
Stefan
More information about the lxml-dev
mailing list