Edirom / Edirom-Online

Edirom Online is a tool for presenting historical-critical music editions in digital form.
GNU General Public License v3.0
19 stars 18 forks source link

issue with function return types #309

Closed peterstadler closed 1 year ago

peterstadler commented 1 year ago

There seems to be a changed behavior with eXist versions > 6.0.1 that now ()/string(@foo) returns an empty-sequence, not a string. Saxon also processes it that way so I believe it to be in alignment with the specs ;)

Various functions in edition.xqm rely on the old buggy behavior, e.g. https://github.com/Edirom/Edirom-Online/blob/ab873e092af1aea89c68d2b1135b856448476f5b/add/data/xqm/edition.xqm#L93-L96

That is, when doc($uri)//edirom:preferences evaluates to the empty sequence, the whole expression will return an empty sequence which is not what the function return type says, hence an error will be raised.

This happens in the Edirom when no resolvable $uri (= $uri equals the empty string) is passed to the function – which is another issue because Edirom relies on some buggy eXist behavior, see https://github.com/eXist-db/exist/issues/3898

Since this affects a lot of functions and I do not have the needed overview, I can only suggest to a) wrap the fn:doc function in a custom function that checks doc-available first (and/or wraps it in a try/catch) b) replace occurrences of some/xpath/string(@someAttribute) with some/xpath/@someAttribute => string()

peterstadler commented 1 year ago

For a) I found a good candidate in eutil:getDoc ?!

bwbohl commented 1 year ago

When fixing please also add a shareable documentation how to fix this in older ediroms

peterstadler commented 1 year ago

When fixing please also add a shareable documentation how to fix this in older ediroms

What do you mean with "older ediroms"? The proposed fix #310 should work for any Edirom that is running on xquery version 3.