Ga naar hoofdinhoud

Transform

The data you access rarely matches the exact model your application or Service Platform needs, so you reshape it. NDE recommends doing this with SPARQL, keeping transformations declarative and portable rather than locked inside bespoke scripts.

Transform RDF with SPARQL CONSTRUCT

For RDF-to-RDF transformations, NDE recommends SPARQL CONSTRUCT: you write a query that reads the source shape and constructs the target shape, often as several small steps chained together. Because the transformation is an ordinary SPARQL query rather than custom code, it is portable across tools and inspectable – the Stack’s SPARQL-native Transformation pattern, used by its pipelines to project source data into search indexes, knowledge graphs and EDM.

When a source has several independently multi-valued properties, split the mapping into small CONSTRUCT queries joined by UNION rather than one query full of OPTIONALs, so multi-valued properties do not multiply into cross-product duplicates.

Transform non-RDF with SPARQL Anything

If your source is not RDF (e.g. a CSV or TSV, JSON, XML or Excel file) you can still use the CONSTRUCT you already know, with SPARQL Anything. It presents any such source through a uniform RDF facade, so you query it with an ordinary CONSTRUCT and a SERVICE block; it does not extend the SPARQL grammar, so your existing skills transfer directly.

For a worked example, see Turning GeoNames into linked data, which converts the 13-million-row GeoNames TSV dump to RDF using nothing but CONSTRUCT.