Skip to content

Clarify LANGMATCHES specification #310

@kasei

Description

@kasei

The current definition of LANGMATCHES reads:

xsd:boolean langMatches (xsd:string language-tag, xsd:string language-range)
Returns true if the language tag (first argument) matches language-range (second argument). Otherwise, the function returns false. Matching is performed according to the basic filtering scheme defined in [RFC4647] section 3.3.1. language-range is a basic language range per Matching of Language Tags [RFC4647] section 2.1. A language-range of "*" matches any non-empty language-tag string. Otherwise, the function returns false.

I think there's an implicit assumption here that the language-range is in fact a valid language range per the RFC (similarly for language-tag being a valid language tag). In most cases, if it weren't I think it would necessarily not match any valid language-tag. However, in the case of language-range being an empty string (which is not a syntactically valid range), I think there's some ambiguity here. A generous reading would just fall through to the "otherwise return false" text, but I think a better handling here would raise an error if the input variables don't conform to the expected form (which in many cases would likely have the same overall behavior as returning false). Either way, I think improving the text to explicitly define what happens in the case of invalid language tags and ranges would be good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions