[1] [[RDF]] における[DFN[[RUBYB[リテラル]@en[literal]]]]は、[[資源]]でない ([[RDF URI参照]]によって表せない)
値です。

* 仕様書

[REFS[
- [4] [CITE@en[RDF 1.1 Concepts and Abstract Syntax]]
( ([TIME[2014-04-26 05:40:41 +09:00]] 版))
<https://dvcs.w3.org/hg/rdf/raw-file/default/rdf-concepts/index.html#h3_section-Graph-Literal>
- [3] [CITE@en[RDF Schema 1.1]]
( ([TIME[2014-02-27 21:42:23 +09:00]] 版))
<https://dvcs.w3.org/hg/rdf/raw-file/default/rdf-schema/index.html#h3_ch_literal>
]REFS]

* 構成要素

[6] [[リテラル]]は、次の3つの要素により構成されます [SRC[>>4]]。

[FIG(list members)[
:[7] [RUBYB[[[字句形]]]@en[lexical form]]: [[Unicode文字列]]。[[NFC]] である[['''べきです''']]。
:[8] [RUBYB[[[データ型IRI]]]@en[datatype IRI]]: [[字句形]]がどう[[リテラル値]]に[[写像]]されるかを決める[[データ型]]の [[IRI]]。
:[9] [F[[RUBYB[[[言語タグ]]]@en[language tag]]]]:
[[BCP 47]] [[言語タグ]]。[[空文字列]]ではない、[[整形式]]の[[言語タグ]]でなければ[MUST[なりません]]。
[SRC[>>4]]
これを指定すると[[言語タグ付き文字列]]となります。

]FIG]

[26] [[字句形]]が [[NFC]] たるべき、という規定は、絶対的な要件ではないものの、
厳しい要件には違いありません。
[[NFC]]
は破壊的な操作で、これが原因で[[文字化け]]が生じるおそれもあります。
従って任意の[[自然言語]]文を記述するために使うのは危険です。
[SEE[ [[正規化]] ]]


[10] [[言語タグ]]は、[[データ型IRI]]が [CODE(URI)[[[http://www.w3.org/1999/02/22-rdf-syntax-ns#langString]]]]
の時に限り含まれます。この場合の[[リテラル]]を特に[[言語タグ付き文字列]]といいます。

* リテラル値

[11] [DFN[[RUBYB[[[リテラル値]]]@en[literal value]]]]は次のように定義されています [SRC[>>4]]。
[FIG[
- [12] [[言語タグ付き文字列]]の場合、[[字句形]]と[[言語タグ]]をこの順に並べた組です。
- [13] [[データ型IRI]]が[[認識されるデータ型IRI]]に含まれなければ、[[未定義]]です。
- [14] それ以外の場合、
-- [15] [[字句形]]が[[字句空間]]内であれば、[[字句から値への写像]]を適用した結果です。
-- [16] そうでなければ [[ill-typed]] であり、[[リテラル値]]はありません。
]FIG]

[17] >>16 は[RUBYB[意味的不整合]@en[semantic inconsistency]]ですが、構文的には非[[整形式]]ではありません。
実装は [[ill-typed]] な[[リテラル]]も受け付けて [[RDFグラフ]]を生成しなければ[['''なりません''']]。
警告を出しても[['''構いません''']]。 [SRC[>>4]]

* 等値性

[18] [[RDFリテラル]]が[DFN[[RUBYB[[[等値]]]@en[equal]]]]であるとは、その[[字句形]]、
[[データ型IRI]]、[[言語タグ]]がいずれも[[文字]]単位で等しいことをいいます [SRC[>>4]]。

;; [19] [[リテラル値]]が等しくても、[[字句形]]が異なれば等しい[[リテラル]]ではありません。

* 歴史

[2] [[RDF 1.0]] では[[リテラル]]には次の種類がありました。

[FIG[
- [[平リテラル]]
- [[型付きリテラル]]
-- [[XMLリテラル]]
]FIG]

[5] [[RDF 1.1]] ではすべて[[型付きリテラル]]になっています。[[平リテラル]]は[[単純リテラル]]と[[言語タグ付き文字列]]に相当します。

[REFS[
- [20] [CITE@en[What’s New in RDF 1.1]] ([TIME[2014-02-21 12:31:39 +09:00]] 版) <http://www.w3.org/TR/rdf11-new/#h3_literals>
]REFS]

[21] [[RDF 1.0]] では任意の[[符号位置]]が認められていたようですが、 [[RDF 1.1]]
では [CODE@en[[[xs:string]]]] なので、 [[U+0000]] を使えず、 [[U+0001]]-[[U+001F]]
は認めなくても良いとされているようです [SRC[>>20]]。

[FIG(quote)[
[FIGCAPTION[
[22] [CITE[NLP Interchange Format (NIF) 2.0 - Core Specification]]
([[Sebastian Hellmann]]著, [TIME[2013-12-05 10:36:30 +09:00]])
<http://persistence.uni-leipzig.org/nlp2rdf/specification/core.html>
]FIGCAPTION]

> According to the RDF 1.1 specification (3.3 Literals), RDF literals are Unicode strings, which should be in Normal Form C (NFC). In NIF, we will follow this recommendation in general. There are, however, circumstances which require the use of Normal Form D (NFD) or even NFKC or NFKD. Therefore NIF allows NFD, NFKC and NFKD, if the use case justifies the usage.
> One such use case is, if a linguistic annotator has the requirement to annotate individual diacritics or parts of precomposed characters and syllables. For linguists with this use case or applicable languages, using NFD is obvious and well-justified. We will only give examples here and refer the interested reader to these three documents: Gernot Katzer's page about the Korean Writing system, Wikipedia article about the Korean Hangul, Unicode Normal Form specification.

]FIG]


[23] [CITE@en-US[RDF Literal Direction Working Group Charter]]
([TIME[2019-06-14 03:20:23 +09:00]])
<https://w3c.github.io/rdf-dir-literal/draft-charter.html>

[24] [CITE@en-US[RDF Literals and Base Directions]]
([TIME[2019-06-14 03:20:23 +09:00]])
<https://w3c.github.io/rdf-dir-literal/>

[25] [CITE@en[w3c/rdf-dir-literal: Proposal to add base direction to RDF Literals]]
([TIME[2019-06-21 14:34:06 +09:00]])
<https://github.com/w3c/rdf-dir-literal>