Typed and language-tagged literals

Numbers, dates, multilingual strings.

0/3 done

Theory

Literals can carry a datatype or a language tag:

:Alice :age 30 .                # xsd:integer (inferred)
:Alice :height "1.72"^^xsd:decimal .
:Alice foaf:name "Alice"@en, "アリス"@ja .

The XSD datatypes you'll meet most often:

DatatypeExample literalNotes
xsd:string"hello"Default for bare strings
xsd:integer42Inferred from bare integers
xsd:decimal"1.72"^^xsd:decimalUse for exact decimals
xsd:booleantruetrue / false keywords
xsd:date"1990-04-12"^^xsd:dateISO-8601 calendar date
xsd:dateTime"2025-05-18T10:30:00Z"^^xsd:dateTimeDate + time + timezone

Analogy

RDF literals are like labeled containers in an international warehouse.

Every value can carry extra meaning about:

  • what kind of data it is
  • how it should be interpreted
  • what language it belongs to

Without labels, systems only see raw text.

With datatypes and language tags, systems understand the meaning of the value.

The Shipping Label Analogy

Imagine packages arriving at a global warehouse.

Some boxes contain:

  • numbers
  • dates
  • measurements
  • multilingual text

If every package were simply labeled “text,” workers would constantly misinterpret the contents.

Instead, each package gets a precise label.

RDF LiteralWarehouse Analogy
"hello"Generic unlabeled package
42Box labeled “integer”
"1.72"^^xsd:decimalPrecision measurement container
trueBoolean yes/no switch
"Alice"@enEnglish-language label
"アリス"@jaJapanese-language label

Example

:Alice :age 30 .
:Alice :height "1.72"^^xsd:decimal .
:Alice foaf:name "Alice"@en , "アリス"@ja .

What the System Understands

LiteralMeaning
30Integer number
"1.72"^^xsd:decimalExact decimal value
"Alice"@enEnglish name
"アリス"@jaJapanese name

Why Datatypes Matter

Datatypes tell machines how values behave.

For example:

  • numbers can be sorted mathematically
  • dates can be compared chronologically
  • booleans can power logic rules
  • decimals preserve precision

Without datatypes, everything becomes ambiguous plain text.

Why Language Tags Matter

Language tags allow the same graph to support multilingual knowledge.

A system can automatically choose:

  • English labels for English users
  • Japanese labels for Japanese users
  • Spanish labels for Spanish users

without changing the graph structure.

Mental Model

Think of RDF literals as smart containers.

The value itself is the content.

The datatype or language tag is the instruction label telling machines:

“Here is how you should interpret this value.”

Common XSD Datatypes

DatatypeExamplePurpose
xsd:string"hello"Generic text
xsd:integer42Whole numbers
xsd:decimal"1.72"^^xsd:decimalExact decimal precision
xsd:booleantrueTrue/false logic
xsd:date"1990-04-12"^^xsd:dateCalendar dates
xsd:dateTime"2025-05-18T10:30:00Z"^^xsd:dateTimeDate + time + timezone

Key Insight

RDF literals are not just text.

They are values enriched with semantic meaning.

Datatypes teach machines how to process data.

Language tags teach machines how to communicate it to humans.

Reading in progress · 0 of 3 activities done