collection('i_do_not_exist')/users/user[@name=()] is () even if i_do_not_exist does not exit

Thursday, 23 March 2023 · 4 messages
OS
Omar Siam23 Mar 2023 14:49 #
Hi, Either I found an interesting new XQuery feature or a bug: collection('i_do_not_exist')/some/path[@attr=()] retruns the empty sequence whereas collection('i_do_not_exist')/some/path throws an error err:FODC0002 so does collection('i_do_not_exist')/some/path[@attr="i_am_an_attr"] Am I missing something? Best regards,
-- Mag. Ing. Omar Siam Austrian Center for Digital Humanities and Cultural Heritage Österreichische Akademie der Wissenschaften | Austrian Academy of Sciences Stellvertretende Behindertenvertrauensperson | Deputy representative for disabled persons Bäckerstraße 13, 1010 Wien, Österreich | Vienna, Austria T: +43 1 51581-7295 omar.siam at oeaw.ac.at | www.oeaw.ac.at/acdh
CG
Christian Grün23 Mar 2023 15:00 #
Hi again, Omar, The behavior may be surprising, but it's valid: If it can be detected at compile time that an expression will never yield results, it can be simplified and rewritten to an empty sequence, no matter if a referenced database may possibly exist at runtime. Hope this helps, Christian
Quoted text · Omar Siam · 26 lines
Omar Siam <Omar.Siam at oeaw.ac.at> schrieb am Do., 23. März 2023, 14:49: > Hi, > > Either I found an interesting new XQuery feature or a bug: > > collection('i_do_not_exist')/some/path[@attr=()] retruns the empty > sequence whereas > > collection('i_do_not_exist')/some/path throws an error err:FODC0002 so > does collection('i_do_not_exist')/ome/path[@attr="i_am_an_attr"] > > Am I missing something? > > Best regards, > > -- > Mag. Ing. Omar Siam > Austrian Center for Digital Humanities and Cultural Heritage > Österreichische Akademie der Wissenschaften | Austrian Academy of Sciences > Stellvertretende Behindertenvertrauensperson | Deputy representative for > disabled persons > Bäckerstraße 13, 1010 Wien, Österreich | Vienna, Austria > T: +43 1 51581-7295 > omar.siam at oeaw.ac.at | www.oeaw.ac.at/acdh > >
OS
Omar Siam23 Mar 2023 15:03 #
Well it is definitly an optimization that is new to BaseX 10. But I think I found a way to default to "" where I just passed () from a variable before.
Quoted text · Christian Grün · 42 lines
Am 23.03.2023 um 15:00 schrieb Christian Grün: > Hi again, Omar, > > The behavior may be surprising, but it's valid: If it can be detected > at compile time that an expression will never yield results, it can be > simplified and rewritten to an empty sequence, no matter if a > referenced database may possibly exist at runtime. > > Hope this helps, > Christian > > > > Omar Siam <Omar.Siam at oeaw.ac.at> schrieb am Do., 23. März 2023, 14:49: > > Hi, > > Either I found an interesting new XQuery feature or a bug: > > collection('i_do_not_exist')/some/path[@attr=()] retruns the empty > sequence whereas > > collection('i_do_not_exist')/some/path throws an error > err:FODC0002 so does > collection('i_do_not_exist')/ome/path[@attr="i_am_an_attr"] > > Am I missing something? > > Best regards, > > -- > Mag. Ing. Omar Siam > Austrian Center for Digital Humanities and Cultural Heritage > Österreichische Akademie der Wissenschaften | Austrian Academy of > Sciences > Stellvertretende Behindertenvertrauensperson | Deputy > representative for disabled persons > Bäckerstraße 13, 1010 Wien, Österreich | Vienna, Austria > T: +43 1 51581-7295 > omar.siam at oeaw.ac.at | www.oeaw.ac.at/acdh > <http://www.oeaw.ac.at/acdh> >
-- Mag. Ing. Omar Siam Austrian Center for Digital Humanities and Cultural Heritage Österreichische Akademie der Wissenschaften | Austrian Academy of Sciences Stellvertretende Behindertenvertrauensperson | Deputy representative for disabled persons Bäckerstraße 13, 1010 Wien, Österreich | Vienna, Austria T: +43 1 51581-7295 omar.siam at oeaw.ac.at |www.oeaw.ac.at/acdh
CG
Christian Grün23 Mar 2023 15:11 #
Quoted text · Omar Siam · 5 lines
> > Well it is definitly an optimization that is new to BaseX 10. But I think > I found a way to default to "" where I just passed () from a variable > before. >
True. With BaseX 10, XQuery compilation was split up into a static (logical) and a dynamic (physical) step to allow for a more fine granular locking. In the static compilation, your expression will be rewritten as follows: collection('i_do_not_exist')/users/user[@name=()] →collection('i_do_not_exist')/users/user[false()] →collection('i_do_not_exist')/users/() →collection('i_do_not_exist')/() →()

⚡Generated with XQuery