Class RML2MappingAlgebra

java.lang.Object
se.liu.ida.hefquin.rml.RML2MappingAlgebra

public class RML2MappingAlgebra extends Object
This class can be used to translated RML mappings into the mapping algebra.

The translation is implemented using the algorithms introduced in the following research paper.

Sitt Min Oo and Olaf Hartig: "An Algebraic Foundation for Knowledge Graph Construction." In Proceedings of the 22nd Extended Semantic Web Conference (ESWC), 2025.

  • Constructor Details

    • RML2MappingAlgebra

      public RML2MappingAlgebra()
  • Method Details

    • convert

      public static MappingOperator convert(org.apache.jena.rdf.model.Resource tm, org.apache.jena.rdf.model.Model rmlDescription, org.apache.jena.graph.Node baseIRI) throws RMLParserException
      This implements lines 4-26 of Algorithm 1 of the paper.
      Parameters:
      tm -
      rmlDescription -
      baseIRI -
      Returns:
      Throws:
      RMLParserException
    • checkSourceAndGetRootQuery

      public static JsonPathQuery checkSourceAndGetRootQuery(org.apache.jena.rdf.model.Resource tm) throws RMLParserException
      Checks that the logical source of the given triples map has rml:JSONPath as its reference formulation and obtains the root iterator query of the logical source.
      Parameters:
      tm - - assumed to represent an RML triples map
      Returns:
      JSONPath query created from the rml:iterator of the logical source
      Throws:
      RMLParserException
    • createSourceReference

      public static SourceReference createSourceReference(org.apache.jena.rdf.model.Resource tm) throws RMLParserException
      Throws:
      RMLParserException
    • extractQueries

      public static Set<String> extractQueries(org.apache.jena.rdf.model.Resource sm, org.apache.jena.rdf.model.Resource pm, org.apache.jena.rdf.model.Resource om, org.apache.jena.rdf.model.Resource jccm, org.apache.jena.rdf.model.Resource jcpm)
      This function implements lines 1-10 of Algorithm 2 of the paper.
      Parameters:
      sm - - the subject map of a triples map
      pm - - the predicate map of the same triples map
      om - - the object map of the same triples map
      jccm - - the child map of om, may be null
      jcpm - - the parent map of om, may be null
      Returns:
    • extractQueriesOfReferenceValuedExprMap

      public static void extractQueriesOfReferenceValuedExprMap(org.apache.jena.rdf.model.Resource termMap, Set<String> queries)
    • extractQueriesOfTemplateValuedExprMap

      public static void extractQueriesOfTemplateValuedExprMap(org.apache.jena.rdf.model.Resource termMap, Set<String> queries)
    • extractQueriesFromTemplate

      public static void extractQueriesFromTemplate(String t, Set<String> queries)
    • createPwithStrings

      public static Map<String,String> createPwithStrings(Set<String> queries)
      This function implements lines 11-13 of Algorithm 2 in a generic way; that is, the resulting map P contains the query string rather than concrete query objects.
      Parameters:
      queries -
      Returns:
    • createP

      public static Map<String,JsonPathQuery> createP(Map<String,String> PwithStrings, org.apache.jena.rdf.model.Resource tm) throws RMLParserException
      Given a version of map P in which the queries are represented just as strings, this function creates a version of P in which the queries are represented as JsonPathQuery objects.
      Parameters:
      PwithStrings -
      tm - - the triples maps for which the given queries have been extracted; this is used only when an exception needs to be thrown
      Returns:
      Throws:
      RMLParserException
    • createReverseP

      public static Map<String,String> createReverseP(Map<String,String> PwithStrings)
    • createExtendExpression

      public static ExtendExpression createExtendExpression(org.apache.jena.rdf.model.Resource u, org.apache.jena.graph.Node baseIRI, Map<String,String> reverseP) throws RMLParserException
      This function implements Algorithm 3 of the paper.
      Parameters:
      u -
      baseIRI -
      reverseP - - maps the extracted query strings to the attributes to which these queries are assigned by P
      Returns:
      Throws:
      RMLParserException
    • split

      public static List<ExtendExpression> split(String t, Map<String,String> reverseP) throws RMLParserException
      Throws:
      RMLParserException