May 02, 2015 .. currentmodule:: rdfextras.sparql.components

components - SPARQL components

class rdfextras.sparql.components.ListRedirect[source]

A utility class for lists of items joined by an operator. ListRedirects with length 1 are a special case and are considered equivalent to the item instead of a list containing it. The reduce function is used for normalizing ListRedirect to the single item (and calling reduce on it recursively)

class rdfextras.sparql.components.PrefixDeclaration(qName, iriRef)[source]

PrefixDecl ::= ‘PREFIX’ QNAME_NS Q_IRI_REF See: http://www.w3.org/TR/rdf-sparql-query/#rPrefixDecl

class rdfextras.sparql.components.BaseDeclaration[source]

BaseDecl ::= ‘BASE’ Q_IRI_REF See: http://www.w3.org/TR/rdf-sparql-query/#rBaseDecl

class rdfextras.sparql.components.ParsedConditionalAndExpressionList(conditionalAndExprList)[source]

A list of ConditionalAndExpressions, joined by ‘||’

class rdfextras.sparql.components.ParsedRelationalExpressionList(relationalExprList)[source]

A list of RelationalExpressions, joined by ‘&&’s

class rdfextras.sparql.components.ParsedPrefixedMultiplicativeExpressionList(prefix, mulExprList)[source]

A ParsedMultiplicativeExpressionList lead by a ‘+’ or ‘-‘

class rdfextras.sparql.components.ParsedMultiplicativeExpressionList(unaryExprList)[source]

A list of UnaryExpressions, joined by ‘/’ or ‘*’ s

class rdfextras.sparql.components.ParsedAdditiveExpressionList(multiplicativeExprList)[source]

A list of MultiplicativeExpressions, joined by ‘+’ or ‘-‘ s

class rdfextras.sparql.components.ParsedString[source]
class rdfextras.sparql.components.ParsedDatatypedLiteral(value, dType)[source]

Placeholder for Datatyped literals This is necessary (instead of instantiating Literals directly) when datatypes IRIRefs are QNames (in which case the prefix needs to be resolved at some point)

class rdfextras.sparql.components.ParsedFilter(filter)[source]
class rdfextras.sparql.components.ParsedExpressionFilter(filter)[source]
class rdfextras.sparql.components.ParsedFunctionFilter(filter)[source]
class rdfextras.sparql.components.FunctionCall(name, arguments=None)[source]
class rdfextras.sparql.components.ParsedArgumentList(arguments)[source]
class rdfextras.sparql.components.ParsedREGEXInvocation(arg1, arg2, arg3=None)[source]
class rdfextras.sparql.components.BuiltinFunctionCall(name, arg1, arg2=None)[source]
class rdfextras.sparql.components.ParsedGroupGraphPattern(triples, graphPatterns)[source]

See: http://www.w3.org/TR/rdf-sparql-query/#GroupPatterns A group graph pattern GP is a set of graph patterns, GPi. This class is defined to behave (literally) like a set of GraphPattern instances.

class rdfextras.sparql.components.BlockOfTriples(statementList)[source]

A Basic Graph Pattern is a set of Triple Patterns.

class rdfextras.sparql.components.GraphPattern(nonTripleGraphPattern=None, filter=None, triples=None)[source]

Complex graph patterns can be made by combining simpler graph patterns. The ways of creating graph patterns are: * Basic Graph Patterns, where a set of triple patterns must match * Group Graph Pattern, where a set of graph patterns must all match using the same variable substitution * Value constraints, which restrict RDF terms in a solution * Optional Graph patterns, where additional patterns may extend the

solution
  • Alternative Graph Pattern, where two or more possible patterns are tried
  • Patterns on Named Graphs, where patterns are matched against named graphs

( GraphPatternNotTriples | Filter ) ‘.’? TriplesBlock?

class rdfextras.sparql.components.ParsedOptionalGraphPattern(groupGraphPattern)[source]

An optional graph pattern is a combination of a pair of graph patterns. The second pattern modifies pattern solutions of the first pattern but does not fail matching of the overall optional graph pattern.

class rdfextras.sparql.components.ParsedAlternativeGraphPattern(alternativePatterns)[source]

A union graph pattern is a set of group graph patterns GPi. A union graph pattern matches a graph G with solution S if there is some GPi such that GPi matches G with solution S.

class rdfextras.sparql.components.ParsedGraphGraphPattern(graphName, groupGraphPattern)[source]

Patterns on Named Graphs, where patterns are matched against named graphs

class rdfextras.sparql.components.IRIRef[source]
class rdfextras.sparql.components.RemoteGraph[source]
class rdfextras.sparql.components.NamedGraph[source]
class rdfextras.sparql.components.BinaryOperator(left, right)[source]
class rdfextras.sparql.components.EqualityOperator(left, right)[source]
class rdfextras.sparql.components.NotEqualOperator(left, right)[source]
class rdfextras.sparql.components.LessThanOperator(left, right)[source]
class rdfextras.sparql.components.LessThanOrEqualOperator(left, right)[source]
class rdfextras.sparql.components.GreaterThanOperator(left, right)[source]
class rdfextras.sparql.components.GreaterThanOrEqualOperator(left, right)[source]
class rdfextras.sparql.components.UnaryOperator(argument)[source]
class rdfextras.sparql.components.LogicalNegation(argument)[source]
class rdfextras.sparql.components.NumericPositive(argument)[source]
class rdfextras.sparql.components.NumericNegative(argument)[source]
class rdfextras.sparql.components.QName[source]
class rdfextras.sparql.components.QNamePrefix(prefix)[source]
class rdfextras.sparql.components.Query(prolog, query)[source]
Query ::= Prolog (
SelectQuery | ConstructQuery | DescribeQuery | AskQuery )

See: http://www.w3.org/TR/rdf-sparql-query/#rQuery

class rdfextras.sparql.components.WhereClause(parsedGraphPattern)[source]

The “where” clause is essentially a wrapper for an instance of a ParsedGraphPattern

class rdfextras.sparql.components.RecurClause(maps, parsedGraphPattern)[source]
class rdfextras.sparql.components.SelectQuery(variables, dataSetList, whereClause, recurClause, solutionModifier, distinct=None)[source]
SelectQuery ::= ‘SELECT’ ‘DISTINCT’? ( Var+ | ‘*’ )
DatasetClause* WhereClause RecurClause? SolutionModifier

See: http://www.w3.org/TR/rdf-sparql-query/#rSelectQuery

class rdfextras.sparql.components.AskQuery(dataSetList, whereClause)[source]

AskQuery ::= ‘ASK’ DatasetClause* WhereClause See: http://www.w3.org/TR/rdf-sparql-query/#rAskQuery

class rdfextras.sparql.components.ConstructQuery(triples, dataSetList, whereClause, solutionModifier)[source]
ConstructQuery ::= ‘CONSTRUCT’
ConstructTemplate DatasetClause* WhereClause SolutionModifier

See: http://www.w3.org/TR/rdf-sparql-query/#rConstructQuery

class rdfextras.sparql.components.DescribeQuery(variables, dataSetList, whereClause, solutionModifier)[source]
DescribeQuery ::= ‘DESCRIBE’
( VarOrIRIref+ | ‘*’ ) DatasetClause* WhereClause? SolutionModifier

http://www.w3.org/TR/rdf-sparql-query/#rConstructQuery

class rdfextras.sparql.components.Prolog(baseDeclaration, prefixDeclarations)[source]

Prolog ::= BaseDecl? PrefixDecl* See: http://www.w3.org/TR/rdf-sparql-query/#rProlog

class rdfextras.sparql.components.RDFTerm[source]

Common class for RDF terms

class rdfextras.sparql.components.Resource(identifier=None, propertyValueList=None)[source]

Represents a sigle resource in a triple pattern. It consists of an identifier (URIRef or BNode) and a list of PropertyValue instances

class rdfextras.sparql.components.TwiceReferencedBlankNode(props1, props2)[source]

Represents BNode in triple patterns in this form: [ :prop1 :val1 ] :prop2 :val2

class rdfextras.sparql.components.ParsedCollection(graphNodeList=None)[source]

An RDF Collection

class rdfextras.sparql.components.SolutionModifier(orderClause=None, limitClause=None, offsetClause=None)[source]
class rdfextras.sparql.components.ParsedOrderConditionExpression(expression, order)[source]

A list of OrderConditions OrderCondition ::= (

(‘ASC’ | ‘DESC’) BrackettedExpression ) | (FunctionCall | Var | BrackettedExpression)
class rdfextras.sparql.components.PropertyValue(property, objects)[source]
class rdfextras.sparql.components.ParsedConstrainedTriples(triples, constraint)[source]

A list of Resources associated with a constraint

rdfextras.sparql.components.ListPrepend(item, list)[source]

Previous topic

algebra - SPARQL Algebra

Next topic

rdfextras.sparql.evaluate - SPARQL Evaluate