Dear Charlie!
Am 01.03.22 um 16:16 schrieb Charlie Clark:
On 1 Mar 2022, at 16:06, Dr. Volker Jaenisch wrote:
Other namespace based python libs like for instance RDFlib solve this problem
generically by adding the namespace to the python property.
Given how central namespaces are to XML and how often conflicts can occur with
abbreviations and prefixes, I don't think what you suggest should be the
standard behaviour.
I agree completely. But it should be an option that can be choose by a
configuration setting, or a parameter.
It might be fine for a small scope like RDF
I would not say that RDF is small :-) In fact it uses all the XML
namespaces.
but I can think of several places in OOXML where it could cause problems.
May you please be so kind and do test such a szenario.
I think that my change is really save.
* It preserves the former behavior : looking up parent namespace first.
(This is generally not correct, see below)
* If one match is fount the match is returned
* If more than one match is found no action is taken : This deals with
conflicting namespaces.
* if no match is found no action is taken
So in case we have indeed a conflicting namespace
foo:{http://foo}/test
bar:{http://bar}/test
<foo:parent>
<foo:test>
</foo:parent>
Lookup of "test" will return <foo:test> since parent namespace is foo.
<bar:parent>
<foo:test>
</foo:parent>
Lookup of "test" will return <bar:test> since parent namespace is bar.
*Ok this is not correct.* In this case nothing should be returned (as it
formerly was in xlml). *Already fixed in GH.*
<parent>
<foo:test>
<parent>
Will return nothing since two answers.
I think the logic should be:
*If lxml find one matching child by property name then this is the
correct answer. If no or more than one child matches not action is taken.*
Matching against the parent namespace is IMHO in no case correct.
Matching against a default namespace if would be a better option.
Still, your suggestion for a namespace-free lookup looks like it could be very
useful.
You are welcome.
Cheers,
Volker
--
=========================================================
inqbus Scientific Computing Dr. Volker Jaenisch
Hungerbichlweg 3 +49 (8860) 9222 7 92
86977 Burggenhttps://inqbus.de
=========================================================
_______________________________________________
lxml - The Python XML Toolkit mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/lxml.python.org/
Member address: [email protected]