Skip to content

SPARQL 1.2 Functions related to initial text direction and language tags #154

@afs

Description

@afs

SPARQL 1.2 Functions for language string literals

Functions:
hasLANG(literal), hasLANGDIR(literal),
LANG(literal), LANGDIR(literal),
STRLANGDIR(xsd:string, xsd:string, xsd:string) , STRLANGDIR(xsd:string, xsd:string, xsd:string).

LANG(literal) is part of SPARQL 1.1 and is extended for rdf:dirLangString.

Accessors:

RDF Term hasLANG hasLANGDIR LANG LANGDIR
"abc"@en true false "en" ""
"abc"@en--ltr true true "en" "ltr"
"abc"@en--LTR true true "en" "ltr"
"abc" false false "" ""
"abc"^^rdf:dirLangString false false "" ""
"abc"^^rdf:langString false false "" ""
"123"^^xsd:integer false false "" ""
<http://example/xyz> error error error error

Constructors:

Constructor Literal
STRLANG("abc", "en") "abc"@en
STRLANG("abc", "") error
STRLANG(123, "") error
STRLANGDIR("abc", "en", "ltr") "abc"@en--ltr
STRLANGDIR("abc", "en", "LTR") error
STRLANGDIR("abc", "en", "") error
STRLANGDIR("abc", "", "ltr") error
STRLANGDIR(123, "", "ltr") error
STRLANGDIR(<x:uri>, "en", "ltr") error

It is possible to write "abc"^^rdf:dirLangString and "abc"^^rdf:langString in N-Triples and Turtle.

The functions hasLang and hasLANGDIR test whether an RDF term has the language tag of initial text direction component. See RDF Concepts, section "Literals". They don't test by datatype.

LANG is in SPARQL 1.1. This determines the choice for LANGDIR when passed a non-literal and the result of LANGDIR(123).

The accessors LANG and LANGDIR return the facet or "" following LANG in SPARQL 1.1.
The argument must be a literal otherwise it is an error.

In these cases, hasLANG/hasLANGDIR is false and the return of LANG and LANGDIR is "".
The facet is not present.

It may be possible to write a literals with text direction but no language tag in some other format (note: for RDF/XML we can require "lang=" if "dir=" is present").

Notes

hasFUNC(arg) is equivalent to FUNC(arg) != "".

The name hasLANG/hasLANGDIR is different in style to isLITERAL etc because the has* tests a component, not the RDF term as a whole.

hasLANG applies to rdf:langString and rdf:dirLangString.

Initial Text direction is canonicalized to lowercase: c.f. langtag being canonicalized in RDF 1.2.

It is not possible to write a literal in Turtle or N-Triples with a text direction but no language tag, nor is it possible to write a literal other than rdf:dirLangString and rdf:langStringwith language tag. These are illegal in RDF Concepts but may be it will occur naturally in other syntaxes as corner cases. The accessors approach works on components and would be well-defined.

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    spec:enhancementChange to enhance the spec without affecting conformance (class 2) –see also spec:editorial

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions