SPARQL-MM extends SPARQL 1.1 to support querying of multimedia data in RDF triplestores, enabling temporal and spatial operations on media fragments as defined by the W3C Media Fragments URI 1.0 specification [[media-frags]]. It is implemented for Sesame, integrates via Java Class Loader Technology, and supports SPARQL 1.2 Federated Query for querying distributed multimedia datasets.

This document is an unofficial draft and subject to change. Feedback is welcome via the GitHub repository.

Introduction

SPARQL-MM (Multimedia Extension for SPARQL 1.1) provides a set of functions to query multimedia data within RDF triplestores. It builds on the SPARQL 1.1 Query Language [[sparql11-query]], the SPARQL 1.2 Federated Query specification [[sparql12-federated-query]], the Media Annotations Ontology [[MA-ONT]], and the W3C Media Fragments URI 1.0 specification [[media-frags]]. The extension focuses on temporal and spatial relationships of media fragments, which are identified using URI syntax as specified in [[media-frags]]. It is implemented for the Sesame framework and available via Maven Central.

This specification outlines the syntax, semantics, and usage of SPARQL-MM functions, including support for federated queries and media fragment handling.

Implementations of SPARQL-MM MUST conform to the SPARQL 1.1 Query Language specification [[sparql11-query]] and SHOULD support the Media Fragments URI 1.0 specification [[media-frags]] for media fragment identification. Support for SPARQL 1.2 Federated Query [[sparql12-federated-query]] is OPTIONAL but MUST adhere to the semantics described in this specification when implemented. All SPARQL-MM functions are OPTIONAL but MUST adhere to the semantics described herein when implemented.

Namespace

The SPARQL-MM functions use the namespace: , prefixed as mm: in queries.

Functions

SPARQL-MM provides functions for temporal and spatial operations on media fragments, identified by the Media Annotations Ontology [[MA-ONT]] class ma:MediaFragment and represented using the URI syntax defined in the W3C Media Fragments URI 1.0 specification [[media-frags]].

Temporal Functions

Temporal functions operate on media fragments with temporal dimensions as defined in [[media-frags]], such as time ranges specified in URI fragments (e.g., #t=10,20).

mm:precedes(?f1, ?f2)
Returns true if the temporal extent of ?f1 precedes ?f2, based on their temporal fragment specifications.
PREFIX rdfs: 
PREFIX mm: 
SELECT ?t1 ?t2
WHERE {
  ?f1 rdfs:label ?t1 .
  ?f2 rdfs:label ?t2 .
  FILTER mm:precedes(?f1, ?f2)
}
ORDER BY ?t1 ?t2
            
mm:temporalIntermediate(?f1, ?f2)
Returns a temporal bounding box between ?f1 and ?f2, computed from their temporal fragment specifications.
PREFIX rdfs: 
PREFIX mm: 
SELECT ?f1 ?f2 (mm:temporalIntermediate(?f1, ?f2) AS ?box)
WHERE {
  ?f1 rdfs:label "a" .
  ?f2 rdfs:label "b" .
}
            
mm:duration(?f1)
Returns the duration of ?f1 as an xsd:duration, derived from its temporal fragment specification.
PREFIX ma: 
PREFIX mm: 
SELECT ?f1
WHERE {
  ?f1 a ma:MediaFragment .
}
ORDER BY mm:duration(?f1)
            

Spatial Functions

Spatial functions operate on media fragments with spatial dimensions as defined in [[media-frags]], such as rectangular regions specified in URI fragments (e.g., #xywh=160,120,320,240).

mm:rightBeside(?f1, ?f2)
Returns true if ?f1 is spatially to the right of ?f2, based on their spatial fragment specifications.
PREFIX rdfs: 
PREFIX mm: 
SELECT ?t1 ?t2
WHERE {
  ?f1 rdfs:label ?t1 .
  ?f2 rdfs:label ?t2 .
  FILTER mm:rightBeside(?f1, ?f2)
}
ORDER BY ?t1 ?t2
            
mm:spatialIntersection(?f1, ?f2)
Returns the spatial intersection of ?f1 and ?f2 as a bounding box, computed from their spatial fragment specifications.
PREFIX rdfs: 
PREFIX mm: 
SELECT ?f1 ?f2 (mm:spatialIntersection(?f1, ?f2) AS ?box)
WHERE {
  ?f1 rdfs:label "a" .
  ?f2 rdfs:label "b" .
}
            
mm:boundingBox(?f1, ?f2)
Returns a bounding box encompassing ?f1 and ?f2, derived from their spatial fragment specifications.
PREFIX rdfs: 
PREFIX mm: 
SELECT ?f1 ?f2 (mm:boundingBox(?f1, ?f2) AS ?box)
WHERE {
  ?f1 rdfs:label "a" .
  ?f2 rdfs:label "b" .
}
            

Federated Query Support

SPARQL-MM supports the SPARQL 1.2 Federated Query specification [[sparql12-federated-query]], enabling queries over distributed RDF datasets containing multimedia data. The extension’s functions can be used within SERVICE clauses to apply temporal and spatial operations on media fragments, as defined in [[media-frags]], across remote endpoints that support SPARQL-MM.

Implementations MUST ensure that federated queries respect the semantics of SPARQL-MM functions and handle media fragment data consistently across endpoints. The following example demonstrates a federated query using SPARQL-MM functions:

PREFIX rdfs: 
PREFIX mm: 
SELECT ?t1 ?t2
WHERE {
  SERVICE  {
    ?f1 rdfs:label ?t1 .
    ?f2 rdfs:label ?t2 .
    FILTER mm:precedes(?f1, ?f2)
  }
}
ORDER BY ?t1 ?t2
      

In this example, the mm:precedes function is applied to media fragments retrieved from a remote SPARQL endpoint, using temporal fragment specifications as per [[media-frags]]. Implementations SHOULD ensure that remote endpoints support SPARQL-MM functions or provide fallback mechanisms.

Integration

SPARQL-MM is implemented for the Sesame triplestore and can be integrated via Java Class Loader Technology. The package is available on Maven Central:


  com.github.tkurz
  sparql-mm
  2.0

      

Implementations MUST ensure compatibility with Sesame’s SPARQL engine, support the Media Annotations Ontology [[MA-ONT]] and the W3C Media Fragments URI 1.0 specification [[media-frags]] for media fragment identification, and optionally support SPARQL 1.2 Federated Query [[sparql12-federated-query]] for distributed queries.

Examples

Additional examples, including federated query use cases and media fragment handling as per [[media-frags]], are available in the test suite of the SPARQL-MM repository [[SPARQL-MM-GITHUB]].

Acknowledgments

Thanks to the contributors to the SPARQL-MM project and the broader Semantic Web community for their work on SPARQL, multimedia ontologies, media fragments, and federated query standards.