Class ExprTransformVirtualBnodeUris

java.lang.Object
org.apache.jena.sparql.expr.ExprTransformCopy
org.aksw.jena_sparql_api.algebra.expr.transform.ExprTransformVirtualBnodeUris
All Implemented Interfaces:
org.apache.jena.sparql.expr.ExprTransform

public class ExprTransformVirtualBnodeUris extends org.apache.jena.sparql.expr.ExprTransformCopy
Decode "blanknode URIs" - i.e. URIs that represent blank nodes, such as bnode://{blank-node-label} This means ?x = <bnode://foobar> becomes encode(?x) = decode(<bnode://foobar>) encode(?x) = 'foobar' Issue: How to deal with queries that test for blank nodes? In principle, this rewrite virtually eleminates them, so maybe the most reasonable approach is to simply rewrite isBlank to true. in fact, the standard bnode function would also have to yield bnode uris instead bnodeLabel(?x) := if ?x is a blank node, return its label as an xsd:string, type error otherwise Auxiliary functions (defined in terms of the aforementioned and SPARQL standard functions) typeError() := abs("") encodeBnodeUri(xsd:string ?x) := URI(CONCAT('bnode://', ?x)) create an URI from a blank node label isBnodeUri(uri) := isURI(?x) && STRSTARTS(STR(?x), 'bnode://') true if uri represents a bnode decodeBnodeUri(uri ?x) := IF(isBnodeURI(?x), STRAFTER(STR(?x), 'bnode://'), typeError()), extract the blank node label from a URI forceBnodeUri(?x) -> IF(isBlank(?x), encodeBnodeURI(bnodeLabel(?x)), ?x) Transformations: - Given ?x = const if(isBnodeURI(const)) { emit bnodeLabel(?x) = decodeBnodeURI(uri) }
Author:
raven
  • Field Details

  • Constructor Details

  • Method Details

    • transform

      public org.apache.jena.sparql.expr.Expr transform(org.apache.jena.sparql.expr.ExprFunctionN func, org.apache.jena.sparql.expr.ExprList args)
      Specified by:
      transform in interface org.apache.jena.sparql.expr.ExprTransform
      Overrides:
      transform in class org.apache.jena.sparql.expr.ExprTransformCopy
    • transform

      public org.apache.jena.sparql.expr.Expr transform(org.apache.jena.sparql.expr.ExprFunction2 func, org.apache.jena.sparql.expr.Expr a, org.apache.jena.sparql.expr.Expr b)
      Specified by:
      transform in interface org.apache.jena.sparql.expr.ExprTransform
      Overrides:
      transform in class org.apache.jena.sparql.expr.ExprTransformCopy
    • copy

      public static <T extends org.apache.jena.sparql.expr.ExprFunction2> T copy(T func, org.apache.jena.sparql.expr.Expr a, org.apache.jena.sparql.expr.Expr b, boolean swapped)
    • bnodeToIri

      public static org.apache.jena.graph.Node bnodeToIri(org.apache.jena.graph.Node node)
    • isBnodeIri

      public boolean isBnodeIri(org.apache.jena.sparql.expr.NodeValue in)
    • decodeBnodeIriFn

      public org.apache.jena.sparql.expr.NodeValue decodeBnodeIriFn(org.apache.jena.sparql.expr.NodeValue in)
    • trySubst

      public org.apache.jena.sparql.expr.ExprFunction2 trySubst(org.apache.jena.sparql.expr.ExprFunction2 func, org.apache.jena.sparql.expr.Expr lhs, org.apache.jena.sparql.expr.Expr b, boolean swapped)
    • rewrite

      public org.apache.jena.query.Query rewrite(org.apache.jena.query.Query query)
    • createTransformFromUdfModel

      public static ExprTransformVirtualBnodeUris createTransformFromUdfModel(org.apache.jena.rdf.model.Model model, Collection<String> activeProfiles, ExprTransformVirtualBnodeUris.BnodeRewriteMode rewriteMode)
    • forceBnodeUris

      public org.apache.jena.sparql.algebra.Op forceBnodeUris(org.apache.jena.sparql.algebra.Op op)
    • main

      public static void main(String[] args)