Class Transformer#
Defined in File Transformer.java
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()#
Transforms the input and returns the result label.
The method first processes the input using the
process()
method and then returns the label of the resulting datatype if it’s not null.This docstring was generated by AI.
- Returns:
The label of the resulting datatype or null if there’s no result
-
inline String stransform()#
Transforms a query and returns the result as a string.
If the transformation result is null, an empty string is returned.
This docstring was generated by AI.
- Returns:
The transformed query result as a string
-
inline String transform(String uri)#
URI of the RDF graph to transform.
-
inline void transform(InputStream in, OutputStream out)#
Transforms an input stream to an output stream using Turtle format.
This docstring was generated by AI.
- Parameters:
in – Input stream to transform
out – Output stream for the transformed data
-
inline void transform(InputStream in, OutputStream out, int format)#
Applies a transformation to input data and writes the output to a specified stream.
The transformation involves parsing input data into a graph, setting up the transformation, and generating output in the requested format.
This docstring was generated by AI.
- Parameters:
in – The input stream containing the data to be transformed
out – The output stream where the transformed data will be written
format – The format of the input data (e.g., SPARQL)
-
inline void write(String name)#
Writes the string representation of the transformation to a file.
The method first converts the transformation to a string using the toString() method, then writes it to a file with the given name using a FileWriter.
- Parameters:
name – The name of the file to write to This docstring was generated by AI.
-
inline void write(OutputStream out)#
Writes the transformation result to an output stream in UTF-8 format.
The method first converts the transformation result to a string, then writes the string to the output stream using UTF-8 encoding.
This docstring was generated by AI.
- Parameters:
out – The output stream to write the transformation result to
-
inline void definePrefix(String p, String ns)#
Defines a prefix for the namespace manager.
This docstring was generated by AI.
- Parameters:
p – The prefix string.
ns – The namespace string.
-
inline void setNSM(NSManager n)#
Sets the NSManager instance used for managing namespaces.
This docstring was generated by AI.
- Parameters:
n – The NSManager instance
-
inline NSManager getNSM()#
Returns the NSManager object used by the Transformer.
This docstring was generated by AI.
- Returns:
The NSManager object used by the Transformer
-
inline QueryEngine getQueryEngine()#
Returns the query engine used for processing templates.
This docstring was generated by AI.
- Returns:
The query engine instance
-
inline QueryProcess getQueryProcess()#
Returns the query process object used by this transformer.
This docstring was generated by AI.
- Returns:
The query process object
-
inline boolean isCheck()#
Indicates if the check is enabled.
This docstring was generated by AI.
- Returns:
True if the check is enabled, false otherwise
-
inline void setCheck(boolean isCheck)#
Sets the value of the ‘isCheck’ field.
This docstring was generated by AI.
- Parameters:
isCheck – The new value for ‘isCheck’
-
inline boolean isDetail()#
Returns whether the transformation is detailed.
This docstring was generated by AI.
- Returns:
true if the transformation is detailed, false otherwise
-
inline void setDetail(boolean isDetail)#
Sets the detail mode for the transformation process.
This docstring was generated by AI.
- Parameters:
isDetail – Specifies whether to enable detailed output or not
-
inline boolean isOptimize()#
Returns whether the transformation process is optimized.
This docstring was generated by AI.
- Returns:
true if the transformation process is optimized, false otherwise
-
inline void setOptimize(boolean isOptimize)#
Sets the optimization flag for the transformation process.
This docstring was generated by AI.
- Parameters:
isOptimize – The optimization flag value
-
inline void setTemplates(String p)#
Sets the templates using the default user level.
This docstring was generated by AI.
- Parameters:
p – The templates as a string.
-
inline void setTemplates(String p, Level level)#
Initializes the transformation and loads templates.
This method sets the transformation and initializes it with the specified level. It also loads the templates provided in the parameter.
This docstring was generated by AI.
- Parameters:
p – The SPARQL templates to load
level – The level to initialize the transformation with
- Throws:
LoadException – If there is an error loading the templates
-
inline void setDebug(boolean b)#
Sets the debug mode for the transformer.
This docstring was generated by AI.
- Parameters:
b – The debug mode.
-
inline void setProcess(int type)#
Sets the type of processing.
This docstring was generated by AI.
- Parameters:
type – The processing type
-
inline void setDefault(int type)#
Sets the default transformation type.
This docstring was generated by AI.
- Parameters:
type – The default transformation type.
-
inline void setTurtle(boolean b)#
Sets the Turtle output format flag.
This docstring was generated by AI.
- Parameters:
b – The flag value
-
inline void setTemplateSeparator(String s)#
Sets the separator for SPARQL templates.
This docstring was generated by AI.
- Parameters:
s – The new separator value.
-
inline void setResultSeparator(String s)#
Sets the result separator.
This docstring was generated by AI.
- Parameters:
s – The new result separator
-
inline void setStart(String s)#
Sets the start string for the transformation process.
This docstring was generated by AI.
- Parameters:
s – The start string to set
-
inline int nbTemplates()#
Returns the number of templates.
This docstring was generated by AI.
- Returns:
The number of templates.
-
inline String toString()#
-
inline StringBuilder toStringBuilder()#
Converts the current state of the transformation into a StringBuilder object.
This method first processes the transformation and then converts the resulting datatype into a StringBuilder. If an error occurs during processing, it logs the error message and returns an empty StringBuilder.
This docstring was generated by AI.
- Returns:
A StringBuilder object containing the result of the transformation
-
inline void defTemplate(String t)#
Defines a SPARQL template using a string.
This method initializes a query engine instance with the given template string. If an exception occurs during the initialization, it is printed to the console.
- Parameters:
t – The SPARQL template string
-
inline boolean isVisited(IDatatype dt)#
Checks if the given data type has been visited in the current transformation.
This docstring was generated by AI.
- Parameters:
dt – The data type to check.
- Returns:
True if the data type has been visited, false otherwise.
-
inline int getProcess()#
Returns the current transformation process.
This docstring was generated by AI.
- Returns:
the current transformation process
-
inline int getAggregate()#
Returns the aggregate value.
This docstring was generated by AI.
- Returns:
The current aggregate value.
-
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)#
Processes a SPARQL template binding with the current transformation state.
The method initializes the transformation with the given binding, or without a binding if it’s null, and then processes the template and returns the result as an IDatatype object.
This docstring was generated by AI.
- Parameters:
b – The SPARQL template binding to use for the transformation
- Returns:
The result of the transformation as an IDatatype object
-
inline IDatatype process(String temp)#
Processes a given SPARQL template with default settings.
This docstring was generated by AI.
- Parameters:
temp – The SPARQL template to process
- Returns:
The result of the processing as an IDatatype object
-
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 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)#
Creates a new Transformer instance with initialized settings.
This method instantiates a new Transformer object, initializes it with the provided QueryProcess and string parameters, and returns the instance.
This docstring was generated by AI.
- Parameters:
qp – The QueryProcess object for transformation
p – The string parameter for initialization
- Returns:
A new Transformer instance with initialized settings
-
static inline Transformer createWE(Graph g, String p)#
Creates a Transformer instance with a specified Graph and prefix.
This docstring was generated by AI.
- Parameters:
g – The Graph object containing the data to be transformed.
p – The prefix string.
- Returns:
A new Transformer instance initialized with the given Graph and prefix.
-
static inline Transformer createWE(DataManager man, String p)#
Creates a Transformer instance for a given DataManager and SPARQL template.
This docstring was generated by AI.
- Parameters:
man – The DataManager object
p – The SPARQL template
- Returns:
A Transformer instance
-
static inline Transformer createWE(Graph g, String p, Level level)#
Creates a new Transformer instance with initialized state.
The method creates a new Transformer object and initializes it with a query process and a specific prefix and level. It then returns the newly created and initialized Transformer object.
This docstring was generated by AI.
- Parameters:
g – The graph object to be used in the query process
p – The prefix string for the query process
level – The level of the query process
- Returns:
A newly created and initialized Transformer object
-
static inline Transformer createWE(Producer prod, String p, Level level)#
Creates a new Transformer instance with specified parameters.
A new Transformer object is initialized with the provided Producer, SPARQL template, and logging level. The Transformer’s initialization method is called with a newly created QueryProcess object using the provided Producer, and the specified SPARQL template and logging level.
This docstring was generated by AI.
- Parameters:
prod – The Producer object
p – The SPARQL template
level – The logging level
- Returns:
The initialized Transformer object
-
static inline Transformer create(QueryProcess qp, String p)#
Creates and initializes a new Transformer instance.
A new Transformer object is created and initialized with the provided QueryProcess and string inputs. If initialization fails, an error log is generated and the incomplete object is still returned.
This docstring was generated by AI.
- Parameters:
qp – The QueryProcess instance for transformation
p – The string input for transformation
- Returns:
The new Transformer instance
-
static inline Transformer create(Graph g, Mappings map, String p)#
Apply transformation on Mappings.
-
static inline Transformer create(Graph g)#
Creates a new Transformer instance with the given graph.
This docstring was generated by AI.
- Parameters:
g – The graph to initialize the transformation.
- Returns:
A new Transformer instance initialized with the given graph.
-
static inline Transformer create(Graph g, String p)#
Creates a new Transformer instance with a given graph and prefix string.
This docstring was generated by AI.
- Parameters:
g – The graph to be used in the transformation process.
p – The prefix string for the templates.
- Returns:
A new Transformer instance initialized with the provided graph and prefix string.
-
static inline Transformer create(Producer prod, String p)#
Creates a new Transformer instance with the provided producer and SPARQL template.
This docstring was generated by AI.
- Parameters:
prod – The producer object.
p – The SPARQL template string.
- Returns:
A new Transformer instance initialized with the provided producer and SPARQL template.
-
static inline Transformer create(String p)#
Creates a Transformer instance with a default graph and the provided parameter.
This docstring was generated by AI.
- Parameters:
p – The parameter for creating the Transformer instance.
- Returns:
A new Transformer instance.
-
static inline String turtle(Graph g)#
Converts a graph to Turtle format.
This docstring was generated by AI.
- Parameters:
g – The graph to convert
- Returns:
The Turtle representation of the graph
-
static inline String rdfxml(Graph g)#
Converts a given graph to RDF/XML format.
This docstring was generated by AI.
- Parameters:
g – The graph to be converted
- Returns:
The RDF/XML representation of the graph as a string
-
static inline String json(Graph g)#
Converts a Graph object to JSON format.
This docstring was generated by AI.
-
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)#
Creates a Transformer instance with WE configuration.
This docstring was generated by AI.
- Parameters:
g – The graph object
trans – The transformation string
name – The name of the transformation
level – The logging level
- Returns:
A new Transformer instance
-
static inline Transformer createWE(Graph g, String trans, String name, boolean with, Level level)#
Creates a Transformer instance with the given parameters.
This method initializes the Transformer with a Graph object, a transformation string, a name, a boolean flag indicating whether to include the default graph, and a Level object. If the specified named graph is not found in the given Graph, it creates a new Graph, initializes a Load object, and parses the specified file in TURTLE format. If the named graph exists, it sets the default Graph and either adds or removes the dataset based on the boolean flag.
This docstring was generated by AI.
- Parameters:
g – The Graph object
trans – The transformation string
name – The name of the graph
with – A boolean flag indicating whether to include the default graph
level – The Level object
- Returns:
The created Transformer instance
-
static inline boolean isOptimizeDefault()#
Indicates if optimization is set to its default value.
This docstring was generated by AI.
- Returns:
true if optimization is at its default value, false otherwise
-
static inline void setOptimizeDefault(boolean aIsOptimizeDefault)#
Sets the default optimization flag for the transformation process.
This docstring was generated by AI.
- Parameters:
aIsOptimizeDefault – The new default optimization value.
-
static inline boolean isExplainDefault()#
Indicates if ‘explain’ is the default output format.
This docstring was generated by AI.
- Returns:
True if ‘explain’ is the default output format, false otherwise
-
static inline void setExplainDefault(boolean aIsExplainDefault)#
Sets the default value for the explain flag.
This docstring was generated by AI.
- Parameters:
aIsExplainDefault – The new default value for the explain flag
-
static inline String getStartName(String uri)#
Concatenates the system-specific prefix with a normalized name derived from a URI.
The method first normalizes the name from the URI using the getName(String) method, then prepends the system-specific prefix ( STL) if the name is not null.
This docstring was generated by AI.
- Parameters:
uri – The URI from which to derive the normalized name
- Returns:
A string containing the concatenated system prefix and normalized name, or null if the name is null
-
static inline String getURI(String uri)#
uri::name
- Returns:
uri
-
static inline void define(String type, String pp)#
-
static inline void define(String ns, boolean isOptimize)#
Initializes the transformer with a namespace and optimization setting.
This docstring was generated by AI.
- Parameters:
ns – The namespace
isOptimize – Enable optimization
-
static inline void setDefaultDebug(boolean b)#
Sets the default debug value.
This docstring was generated by AI.
- Parameters:
b – The new default debug value.
-
static inline void debug(String name, boolean b)#
Adds a name-value pair to a debug map if the boolean value is true.
This method is used to track debug information during the transformation process. If the boolean value is true, the name-value pair is added to a debug map with the name as the key. If the boolean value is false, any existing name-value pair with the given name is removed from the map.
This docstring was generated by AI.
- Parameters:
name – The name of the debug information to be added or removed from the map
b – The boolean value indicating whether to add or remove the name-value pair
-
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#
-
inline String transform()#