Façade-X Mappings

Mappings from source formats to Façade-X.

Draft Community Group Report

Latest published version:
https://w3c-facade-x.github.io/facade-x-specs/mappings.html
Latest editor's draft:
https://w3c-facade-x.github.io/facade-x-specs/dev/mappings.html
Editors:
(Università Telematica San Raffaele - Roma)
(The Open University)
Feedback:
GitHub w3c-facade-x/facade-x-specs (pull requests, new issue, open issues)

Abstract

This page lists the Façade-X format mappings. A format mapping specifies how resources in one source format are represented as Façade-X data sources, using the metamodel and the Schema vocabulary.

Status of This Document

This specification was published by the Data Façades Community Group. It is not a W3C Standard nor is it on the W3C Standards Track. Please note that under the W3C Community Contributor License Agreement (CLA) there is a limited opt-out and other conditions apply. Learn more about W3C Community and Business Groups.

This is version 0.1 of this document, released on 2026-10-06, at https://w3c-facade-x.github.io/facade-x-specs/0.1/mappings.html. This version will not change. The latest release is always at https://w3c-facade-x.github.io/facade-x-specs/mappings.html. The editor's draft, which may include changes made after this release, is at https://w3c-facade-x.github.io/facade-x-specs/dev/mappings.html. The issues addressed in this release, and those still open, are listed in the release notes.

This document is currently in active development. The list of formats and the status of each mapping will change as drafts are added.

GitHub Issues are preferred for discussion of this specification.

Set of Documents

This document is one of seven Façade-X specification documents produced by the Data Façades Community Group:

  1. Façade-X Overview
  2. Façade-X Primer
  3. Façade-X Schema vocabulary
  4. Façade-X Engine vocabulary
  5. Façade-X Data Access in SPARQL
  6. Façade-X Concepts and Metamodel Specification
  7. Façade-X Mappings (this document)

1. Introduction

This section is non-normative.

Each format mapping specifies:

A format mapping is selected by the media type of the resource, given by fxe:media-type or inferred by the engine.

2. Issues

Issue 41: Surface form of literals in format mappings (JSON numbers as a first case) Mapping: JSONFX Mappings

The starting point is the idea that Facade-X should not modify the lexical form of data values. Previously, we mapped JSON numerals to xsd:decimal (see also SPARQL-Anything/sparql.anything#620)

However, JSON numerals and xsd:decimal lexical forms are not the same set: JSON allows exponents (1.5e3) and xsd:decimal does not. Keeping the source text, therefore, produces ill-typed literals, so the mappings need a shared rule for when to keep a value's surface form and when to rewrite it as the canonical form. Cases of mismatches between format specifications and XSD datatypes may arise. We should discuss this issue more generally and then make a decision that can guide future mappings.

We review first what SPARQL Anything does, then discuss potential solutions.

SPARQL Anything behaviour

SPARQL Anything types every JSON number as xsd:decimal and copies the numeral from the source as the lexical form. From tests/json/2-features:

JSON SPARQL Anything output
42 "42"^^xsd:decimal
3.0 "3.0"^^xsd:decimal
-0 "0"^^xsd:decimal
1.5e3 "1.5e3"^^xsd:decimal
2E-4 "2E-4"^^xsd:decimal
12345678901234567890 "12345678901234567890"^^xsd:decimal

The last two exponent rows are ill-typed literals. The lexical space of xsd:decimal is (\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+), with no exponent notation (XSD 1.1 Part 2, §3.3.3.1). A SPARQL engine cannot compute a value for them, so numeric comparisons and arithmetic on them fail. The behaviour is also inconsistent with itself: 3.0 keeps its surface form, but -0 is normalised to 0.

The underlying inconsistency

JSON and XSD agree on the values but not on the numerals:

Decision in the JSON mapping draft

Every literal produced is well-typed and exactly equal in value to the JSON number. The surface form is kept wherever XSD allows it.

What changes compared with SPARQL Anything

JSON SPARQL Anything Draft
1.5e3 "1.5e3"^^xsd:decimal (ill-typed) "1500"^^xsd:decimal
2E-4 "2E-4"^^xsd:decimal (ill-typed) "0.0002"^^xsd:decimal
-0 "0"^^xsd:decimal "-0"^^xsd:decimal

All other numbers are unchanged. The expected output of tests/json/2-features needs updating to match, and SPARQL Anything needs a fix.

The general question: surface form versus value

Façade-X aims to represent the source as it is, which argues for keeping the surface form of values. In RDF, though, a typed literal ties the surface form to a datatype's lexical space, and source grammars rarely match XSD lexical spaces exactly. Surface form also matters beyond values: "3.0"^^xsd:decimal and "3"^^xsd:decimal are equal values but different RDF terms, so sameTerm, DISTINCT and joins on literals depend on the lexical form.

This will come up in every mapping whose source format has typed values: YAML (numbers, booleans, dates), spreadsheets (numbers stored as doubles, dates as serial numbers), and possibly XML if schema-aware typing is considered. CSV and plain XML avoid it only because all their values are strings.

Options for a principle shared by all mappings:

  1. Keep the surface form when it is valid for the target datatype; otherwise use the canonical form. This is the current draft. It is well-typed, but some surface forms are lost, and a reader cannot tell which values were rewritten.
  2. Always use the canonical form. Deterministic, but loses the surface form everywhere (3.0 → 3).
  3. Always keep the surface form, with a datatype whose lexical space accepts it. Use the XSD datatype when the source form is in its lexical space; otherwise use a datatype that accepts the source grammar.
  4. Keep the surface form, even if ill-typed. This is the current SPARQL Anything behaviour, and not something a specification should require.

Proposal: option 3

The source text of every value is its lexical form, and no value is rewritten. The datatype is chosen so that the literal is well-typed. In the case of JSON numerals, we first map to xsd:decimal (design choice) and then verify conformance with the surface form:

If agreed, this becomes a common principle in the format mappings page: "The lexical form of a value is its source form. The datatype is the natural XML Schema datatype for the value when the source form is in its lexical space; otherwise it is a datatype whose lexical space accepts the source form, as defined by the mapping." The JSON draft and tests/json/2-features would then be updated accordingly. Opinions welcome.

3. Common principles

The following principles apply to every format mapping, unless the mapping states otherwise.

Values are strings. Every value is a literal of type xsd:string, unless the source format defines its own value types. Engines MUST NOT infer types from the lexical form of a string.

Lexical forms are kept. The lexical form of a value is its form in the source; engines MUST NOT rewrite it. When the source format defines value types, the datatype of a value is chosen so that the literal is well-typed:

  1. the natural XML Schema datatype for the source type, when the source form is in its lexical space;
  2. otherwise, another XML Schema datatype whose lexical space accepts the source form;
  3. otherwise, xsd:string.

Each mapping specifies this decision for its value types (see issue #41).

Order is kept. Where the source format orders its members, the order is kept in the numbers of the container-membership properties rdf:_1, rdf:_2, …, starting from 1.

Names become slot IRIs. Where a source member has a name (a key, a column header, an element or attribute name), the slot is a property whose IRI is minted from that name and the value of fxe:namespace. The minting rules are shared by all mappings; see issue #9.

Container identity. Containers are blank nodes, unless fxe:blank-nodes is false. Deterministic container IRIs are discussed in issue #17.

Mapping options apply. The mapping options of the Engine vocabulary (for example fxe:trim-strings and fxe:null-string) apply to every format.

4. Formats

Format Media types Status Document Issue
CSV text/csv, text/tab-separated-values Draft CSV mapping #29
JSON application/json Draft JSON mapping #30
XML application/xml, text/xml Draft XML mapping #31
HTML text/html Not started — —
Markdown text/markdown Not started — —
YAML application/yaml Not started — —
Spreadsheets XLS, XLSX Not started — —
Text text/plain Not started — —
Folders and archives ZIP, TAR, file system Not started — —

Whether XML and HTML share a single mapping based on the Document Object Model is an open question (see the 2026-07-06 meeting).

5. Tests

Test cases for the format mappings are maintained in the facade-x-tests repository, organised by format.