This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 30264 - [FO31] fn:lang fringe cases
Summary: [FO31] fn:lang fringe cases
Status: NEW
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 3.1 (show other bugs)
Version: Recommendation
Hardware: PC Windows NT
: P2 minor
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
Depends on:
Reported: 2018-06-13 11:40 UTC by Abel Braaksma
Modified: 2018-06-13 11:40 UTC (History)
0 users

See Also:


Description Abel Braaksma 2018-06-13 11:40:56 UTC
I was wondering about the following situations:

* fn:lang('en', /), I think this never matches (root node has no xml:lang attribute)

* fn:lang('', x), given any xml:lang attribute. The spec suggests that this never matches because after a "start-with" match, the remnant should start with "-"

* fn:lang('', x) when <x xml:lang="-" />, I think this should match, but we do not say anything about whether we ought to match invalid languages. Note that xs:lang("-") is invalid

* fn:lang('-en', x) when <x xml:lang="-en" />, I think this should match for the same reasons.

* fn:lang('-', x) when <x xml:lang="--" />, I think this should match too (the spec says that after a "start-with" match, the remnant should start with "-")

* fn:lang(' en-US', x) when <x xml:lang=" en-US " />, I think this should not match (space is significant)

Note that the text says, point (2): "$testlang is equal to some substring of the string-value". I'm not sure why the word "some" is chosen, as there seems to be at most one such substring that starts at the beginning of the string.

If there's a possibility in an up-and-coming erratum to clarify this, I'd suggest to add something like:

* The above rules do not validate the xml:lang value, nor do they impose a maximum length, where the xs:language type would have such restrictions.
* Whitespace in the xml:lang value is significant
* The empty string matches only when xml:lang starts with a dash.

PS: I don't think the spec is in error here, the rules, when applied literally, leave little or no wiggle room