Class Transformer#

Inheritance Relationships#

Base Type#

  • public TransformProcessor

Class Documentation#

class Transformer : public TransformProcessor#

SPARQL Template Transformation Engine.

Use case: translate SPIN RDF into SPARQL concrete syntax pprint OWL 2 RDF in functional syntax Use a list of templates : template { presentation } where { pattern } Templates are loaded from a directory or from a file in .rul format (same as rules) st:apply-templates(?x) : execute one template on ?x st:apply-templates-with(st:owl, ?x) : execute one template on ?x st:apply-all-templates(?x) : execute all templates on ?x st:call-template(uri, ?x) execute named template

Olivier Corby, Wimmics INRIA I3S - 2012

Public Functions

inline String transform()#
inline String stransform()#
inline String transform(String uri)#

URI of the RDF graph to transform.

inline void transform(InputStream in, OutputStream out)#
inline void transform(InputStream in, OutputStream out, int format)#
inline void write(String name)#
inline void write(OutputStream out)#
inline void definePrefix(String p, String ns)#
inline void setNSM(NSManager n)#
inline NSManager getNSM()#
inline QueryEngine getQueryEngine()#
inline QueryProcess getQueryProcess()#
inline boolean isCheck()#
inline void setCheck(boolean isCheck)#
inline boolean isDetail()#
inline void setDetail(boolean isDetail)#
inline boolean isOptimize()#
inline void setOptimize(boolean isOptimize)#
inline void setTemplates(String p)#
inline void setTemplates(String p, Level level)#
inline void setDebug(boolean b)#
inline void setProcess(int type)#
inline void setDefault(int type)#
inline void setTurtle(boolean b)#
inline void setTemplateSeparator(String s)#
inline void setResultSeparator(String s)#
inline void setStart(String s)#
inline int nbTemplates()#
inline String toString()#
inline StringBuilder toStringBuilder()#
inline void defTemplate(String t)#
inline boolean isVisited(IDatatype dt)#
inline int getProcess()#
inline int getAggregate()#
inline IDatatype process()#

Transform the whole graph (no focus node) Apply template st:start, if any Otherwise, apply the first template that matches without bindings.

inline IDatatype process(Binding b)#
inline IDatatype process(String temp)#
inline IDatatype process(String temp, boolean all, String sep, Expr exp, Environment env)#

Run transformation when there is no focus node Usually it runs the st:start template.

inline int level()#
inline int maxLevel()#
inline int getLevel()#
inline void setLevel(int n)#
inline boolean isStart()#
inline IDatatype process(Node node)#
inline IDatatype process(IDatatype dt)#
inline IDatatype process (IDatatype[] a)
inline IDatatype template (String temp, IDatatype dt)
inline IDatatype process(String temp, IDatatype... ldt)#
inline IDatatype process(String temp, Binding b, IDatatype... ldt)#
inline IDatatype process (IDatatype dt, IDatatype[] args, String temp, boolean allTemplates, String sep, Expr exp)

exp: the fun call, eg st:apply-templates(?x) dt: focus node args: list of args, may be null temp: name of a template (may be null) allTemplates: execute all templates on focus and aggregate results sep: separator in case of allTemplates use case: template { st:apply-templates(?w) } where { ?w } Search a template that matches ?w By convention, ?w is bound to ?in, templates use variable ?in as focus node in where clause and ?out as output node Execute the first template that matches ?w (all templates if allTemplates = true) Templates are sorted more “specific” first using a pragma {st:template st:priority n } A template is applied only once on one node, args, hence we store in a stack : node args -> template context of evaluation: it is an extension function of a SPARQL query select (st:apply-templates(?x) as ?px) (concat (?px …) as ?out) where {}.

inline IDatatype process (String temp, boolean allTemplates, String sep, Expr exp, Environment env, IDatatype dt, IDatatype[] args)
inline IDatatype getResult(Mappings map)#
inline Query getTemplate(String temp)#
inline boolean isDefined(String name)#
inline IDatatype tabulate()#
inline StringBuilder tab()#
inline StringBuilder tab(int n)#
inline IDatatype turtle(IDatatype dt)#

display RDF Node in its Turtle syntax

inline IDatatype turtle(IDatatype dt, boolean force)#

force = true: if no prefix generate prefix

inline IDatatype qnameURI(IDatatype dt)#

if prefix exists, return qname, else return URI as is (without <>)

inline IDatatype xsdLiteral(IDatatype dt)#

Display a Literal with its ^^xsd:datatype Use case: OWL 2 functional syntax.

inline void check()#

Check templates that would never succeed Check if a template edges not exist in graph remove those templates from the list to speed up PRAGMA: does not take RDFS entailments into account

inline void trace()#
inline void nbcall()#
inline boolean isHide()#
inline void setHide(boolean isHide)#
inline Graph getGraph()#
inline boolean isTrace()#
inline void setTrace(boolean isTrace)#
inline boolean isHasDefault()#
inline void setHasDefault(boolean hasDefault)#
inline Dataset getDataset()#
inline void setDataset(Dataset dataset)#
inline String getTransformation()#
inline Context getContext()#
inline void setContext(Context context)#
inline void complete(Query q, Transformer ct)#

Query q is the calling template/query Transformer ct is the calling Transformer which contains q this new Transformer inherit information from query and calling transformer (if any)

inline void complete(Query q)#

QueryEngine call complete(q) for all templates.

inline TemplateVisitor getVisitor()#
inline HashMap<String, Transformer> getTransformerMap()#
inline void setTransformerMap(HashMap<String, Transformer> transformerMap)#
inline Binding getBinding()#
inline void setBinding(Binding binding)#
inline Mappings getMappings()#
inline void setMappings(Mappings map)#
inline QuerySolverVisitorTransformer getEventVisitor()#
inline void setEventVisitor(QuerySolverVisitorTransformer eventVisitor)#
inline boolean isStarting()#
inline void setStarting(boolean starting)#
inline Level getAccessLevel()#
inline void setAccessLevel(Level AccessLevel)#
inline boolean isEvent()#
inline void setEvent(boolean event)#

Public Members

boolean stat = !true#

Public Static Functions

static inline List<String> getFormatList(String name)#

Definition of synonym st:all -> (st:xml st:json …)

static inline Transformer createWE(QueryProcess qp, String p)#
static inline Transformer createWE(Graph g, String p)#
static inline Transformer createWE(DataManager man, String p)#
static inline Transformer createWE(Graph g, String p, Level level)#
static inline Transformer createWE(Producer prod, String p, Level level)#
static inline Transformer create(QueryProcess qp, String p)#
static inline Transformer create(Graph g, Mappings map, String p)#

Apply transformation on Mappings.

static inline Transformer create(Graph g)#
static inline Transformer create(Graph g, String p)#
static inline Transformer create(Producer prod, String p)#
static inline Transformer create(String p)#
static inline String turtle(Graph g)#
static inline String rdfxml(Graph g)#
static inline String json(Graph g)#
static inline Transformer createWE(Graph g, String trans, String name)#

Create Transformer for named graph system named graph, std named grapĥ: use Dataset from name loaded graph.

static inline Transformer createWE(Graph g, String trans, String name, Level level)#
static inline Transformer createWE(Graph g, String trans, String name, boolean with, Level level)#
static inline boolean isOptimizeDefault()#
static inline void setOptimizeDefault(boolean aIsOptimizeDefault)#
static inline boolean isExplainDefault()#
static inline void setExplainDefault(boolean aIsExplainDefault)#
static inline String getStartName(String uri)#
static inline String getURI(String uri)#

uri::name

Returns:

uri

static inline void define(String type, String pp)#

Deprecated:

static inline void define(String ns, boolean isOptimize)#
static inline void setDefaultDebug(boolean b)#
static inline void debug(String name, boolean b)#
static inline int getCount()#
static inline String getPP(String type)#
static inline Table getTable()#

Public Static Attributes

static final String SQL   = STL + "sql"
static final String SPIN   = STL + "spin"
static final String TOSPIN   = STL + "tospin"
static final String OWL   = STL + "owl"
static final String OWLRL   = STL + "owlrl"
static final String OWL_RL   = STL + "owlrl"
static final String OWL_EL   = STL + "owleltc"
static final String OWL_QL   = STL + "owlqltc"
static final String OWL_TC   = STL + "owltc"
static final String OWL_MAIN   = STL + "main"
static final String PP_ERROR   = STL + "pperror"
static final String PP_ERROR_MAIN   = STL + "main"
static final String PP_ERROR_DISPLAY   = STL + "display"
static final String DATASHAPE   = STL + "dsmain"
static final String TEXT   = STL + "text"
static final String TURTLE   = STL + "turtle"
static final String TURTLE_HTML   = STL + "hturtle"
static final String RDFXML   = STL + "rdfxml"
static final String ALL   = STL + "all"
static final String XML   = STL + "xml"
static final String RDF   = STL + "rdf"
static final String JSON   = STL + "json"
static final String JSON_LD   = STL + "jsonld"
static final String TRIG   = STL + "trig"
static final String TABLE   = STL + "table"
static final String HTML   = STL + "html"
static final String SPARQL   = STL + "sparql"
static final String RDFRESULT   = STL + "result"
static final String NAVLAB   = STL + "navlab"
static final String RDFTYPECHECK   = STL + "rdftypecheck"
static final String SPINTYPECHECK   = STL + "spintypecheck"
static final String STL_PROFILE   = STL + "profile"
static final String STL_START   = STL + "start"
static final String STL_MAIN   = STL + "main"
static final String STL_TRACE   = STL + "trace"
static final String STL_DEFAULT   = Processor.STL_DEFAULT
static final String STL_DEFAULT_NAMED   = STL + "defaultNamed"
static final String STL_OPTIMIZE   = STL + "optimize"
static final String STL_IMPORT   = STL + "import"
static final String STL_PROCESS   = Processor.STL_PROCESS
static final String STL_AGGREGATE   = Processor.STL_AGGREGATE
static final String STL_TRANSFORM   = Context.STL_TRANSFORM
static final String STL_PREFIX   = Context.STL_PREFIX
static final String D3   = NSManager.D3
static final String D3_ALL   = D3 + "all"
static final String [] RESULT_FORMAT   = { XML, JSON, RDF }
static final String [] GRAPHIC_FORMAT   = { D3 + "graphic", D3 + "hierarchy" }
static final String PPRINTER   = TURTLE
static final String IN   = ASTQuery.IN
static final String IN2   = ASTQuery.IN2
static boolean DEFAULT_DEBUG = false#
static int count = 0#