https://vocab.methodandstructure.com/transformation#tfoThis document defines a vocabulary for representing the description and application of pure functions that transform byte segments. It is intended primarily for functions over HTTP representations—i.e., the actual literal payloads of HTTP messages—but can be used to represent other such functions.
Many, if not most Web content manipulation tasks are concerned exclusively with representations: the literal contents of HTTP messages, rather than abstract or internal representations. Such manipulations may include excerpting and rearranging files, compressing and decompressing, cropping and resizing images, and converting between data formats. If we separate these operations from other development tasks, we can reuse them.
The purpose of this vocabulary is to provide a mechanism for identifying pure functions that transform opaque data segments (like HTTP response bodies) and perhaps take additional scalar parameters (and specify both named and sequential calling conventions), and relate a function definition to a concrete implementation. The vocabulary also provides terms to represent memoizing the (potentially partial) application of a function to a particular data object, i.e., relating a particular input (plus any additional parameters) to a particular output.
Consider the following example:
@prefix tfo: <https://vocab.methodandstructure.com/transformation#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix skos: <http://www.w3.org/2004/02/skos/core#> . @prefix dct: <http://purl.org/dc/terms/> . @prefix prov: <http://www.w3.org/ns/prov#> . @prefix ex: <https://example.club/#> . ex:range a tfo:Function ; skos:prefLabel "Byte Range"@en ; skos:description "Select a subset of bytes from a given segment."@en ; tfo:accepts "*/*"^^tfo:content-type ; tfo:returns "*/*"^^tfo:content-type ; tfo:parameter ex:start, ex:end ; tfo:parameter-list ( ex:start ex:end ) ; tfo:implementation <jar:functions.jar!org/foobar/textproc/ByteRange.class> . ex:start a tfo:Parameter ; dct:identifier "start"^^xsd:token ; rdfs:comment "The beginning offset (omission interpreted as zero)."@en ; owl:maxCardinality 1 ; rdfs:range xsd:nonNegativeInteger . ex:end a tfo:Parameter ; dct:identifier "end"^^xsd:token ; rdfs:comment "The ending offset (omission interpreted as the end of the input)."@en ; owl:maxCardinality 1 ; rdfs:range xsd:nonNegativeInteger . <urn:uuid:1d85f168-1710-4bc8-b68b-c7513483c228> a tfo:Invocation ; prov:startedAtTime "2020-01-20T16:46:27.043Z"^^xsd:dateTime ; prov:endedAtTime "2020-01-20T16:46:27.051Z"^^xsd:dateTime ; tfo:transform ex:range ; tfo:input <ni:///sha-256;fzhKzqnfAxmB9ICBwe00Dq3smuo43J2K-58uL_62t6Q> ; ex:start 1234 ; ex:end 31337 ; tfo:output <ni:///sha-256;QqNiOgLJk13nOs8Mn4prYtEIZZfwuiju2y4cT_YCOlI> .
The preceding example defines a transformation function, along with its parameters, and relates it to a fictional implementation embedded in a JAR somewhere (the exact way an implementation is resolved is out of scope for this vocabulary). At the bottom is an imaginary application of the transformation function, along with values for supplied parameters. The input and output are designated by digest URIs, which can be resolved to their corresponding representations.
This vocabulary extends the Data Catalog Vocabulary by making tfo:Function a subclass of dcat:DataService and the Provenance Ontology, by way of refining the prov:Activity class and related properties. For instance, a record can use its inherited PROV properties to store metrics on the time it took to execute the function over the input.
The Transformation Functions Ontology includes a basic bundling class that affords the reuse of parameters, e.g. for configuration.
BundleThis class provides a basic mechanism to yoke a set of transformation functions together.
dcat:Catalogprov:SoftwareAgenttfo:implementationA tfo:Function is essentially a function definition, specifying input and output constraints, and parameters in both named and positional representations.
FunctionThis class provides a specification for a transformation function.
dcat:DataServiceprov:Entitytfo:parametertfo:parameter-listtfo:acceptstfo:returnstfo:preferstfo:precedestfo:followstfo:triggerstfo:by-uritfo:not-by-uriMarkupTransformThis class represents the set of transformation functions that operate exclusively over (HTML/XML) markup.
tfo:Functiontfo:by-xpathtfo:not-by-xpathtfo:Parameter entities encapsulate name, type, and cardinality of a given function parameter, while tfo:ParameterList entities specify position.
ParameterThis class provides a specification for a parameter in a given function.
rdf:Propertyrdfs:domain ∈
(tfo:Partial ∪ tfo:Bundle)
tfo:defaulttfo:emptytfo:shifttfo:universeCompositeA composite parameter has a multi-valued value like a list, tuple, set or range.
tfo:Parametertfo:elementrdf:Bagrdf:Listtfo:RangeParameterListThis class represents a list with the restriction that its members be tfo:Parameter nodes.
rdf:Listrdf:first ∈ tfo:Parameter
rdf:rest ∈ tfo:ParameterList
RangeA span of numbers or sequence-able objects, like dates.
rdfs:Containertfo:lowtfo:hightfo:infimumtfo:supremumQueues are how we bundle sequences of tfo:Function (or tfo:Partial) for execution. Queue
is something of a misnomer, as the sequence of transforms need not be explicitly asserted, but rather negotiated on the fly.
QueueA queue is a collection of tfo:Function (and/or tfo:Partial) elements, organized either by explicit sequence (via tfo:member-list), or by dynamic sorting at runtime.
prov:Activitytfo:membertfo:member-listtfo:firsttfo:lasttfo:nextStrictQueueA strict queue is one for which all its elements must be executed, unlike an ordinary queue which only has to attempt to run its contents.
tfo:QueueAddressableQueueAn addressable queue is a strict queue intended to hold transforms that have been invoked through the URL.
tfo:StrictQueueFunctionListA function list is a list that only holds tfo:Function or tfo:Partial entities.
rdf:Listrdf:first ∈
tfo:Function
∪ tfo:Partial
rdf:rest ∈ tfo:FunctionList
InsertionAn insertion is a pre-packaged event that manipulates a per-request instance of a transformation queue. When the result of the transform being run matches the condition, the contents of the tfo:Insertion are inserted into the target queue.
tfo:Queuetfo:conditiontfo:targetRecording partial and full function invocations is important for memoizing computations.
InvocationThis class represents an invocation of a transformation function, connecting a specific input and scalar parameters with its output.
tfo:Partialtfo:Applicationtfo:completestfo:inputtfo:outputPartialThis class represents a partial application of a transformation function, affording the encapsulation and re-use of existing parameters.
prov:Activitytfo:transformThese properties have to do with specifying tfo:Function entities and their parameters.
acceptsSpecifies the list of content-types, in order of preference, that the function can process.
dcat:DataServicetfo:content-type ∪ rdf:List
returnsSpecifies the list of content-types, in order of preference, that the function is capable of returning.
dcat:DataServicetfo:content-type ∪ rdf:List
prefersSpecifies the tfo:content-type the transform prefers to emit in lieu of a preference specified by the request. May be a list.
tfo:returnstfo:Functiontfo:content-type ∪ rdf:List
implementationURI to the implementation of the function.
tfo:Bundlerdfs:ResourceparameterBinds a parameter object to its function.
dcat:Resourcetfo:Parameterparameter-listSpecifies the sequence of parameters when the invocation method of the function is sequential.
dcat:Resourcetfo:ParameterListelementThis property designates an elementary type to go into the composite type.
tfo:Compositerdfs:DatatypedefaultSpecifies one or more default values for a parameter.
tfo:ParameteruniverseSpecifies the container that contains the universe
of values that a paramter can take.
tfo:Parameterrdfs:ContaineremptyFlags whether an empty parameter value should be treated as input rather than ignored.
tfo:Parameterxsd:booleanshiftFlags whether a parameter with multiple values but a fixed cardinality shift off the front of the list rather than truncate off the back.
tfo:Parameterxsd:booleanlowSpecifies the lower bound of a tfo:Range.
tfo:Rangerdfs:LiteralhighSpecifies the upper bound of a tfo:Range.
tfo:Rangerdfs:LiteralinfimumFlags whether a tfo:Range will be open on the low side.
tfo:Rangexsd:booleansupremumFlags whether a tfo:Range will be open on the high side.
tfo:Rangexsd:booleanThese properties all have to do with providing hints to topological sorts of transforms within queues, or otherwise explicit sequences.
memberDenotes a member of a queue.
tfo:Queuetfo:Function ∪ tfo:Partial
member-listDenotes an explicit member list for a queue.
tfo:Queuetfo:FunctionListprecedesSpecifies one or more tfo:Function that the subject must precede in a queue.
tfo:Functiontfo:Functiontfo:followsfollowsSpecifies one or more tfo:Function that the subject must follow in a queue.
tfo:Functiontfo:Functiontfo:precedesnextSpecifies the next queue to run after this one.
tfo:Queuetfo:QueuefirstExplicitly specifies a transform that must go first.
tfo:membertfo:Queuetfo:Function
∪ tfo:Partial
lastExplicitly specifies a transform that must go last.
tfo:membertfo:Queuetfo:Function
∪ tfo:Partial
These properties relate trnasforms to queue insertion events.
triggersA tfo:Function can trigger an tfo:Insertion event on a certain condition (e.g., successful completion).
tfo:Functiontfo:InsertiontargetA target queue for the insertion.
tfo:Insertiontfo:QueueconditionAn HTTP status code for which the insertion is triggered.
tfo:Insertionht:StatusCodeThis group of properties is responsible for relating tfo:Function to the actual data objects they transform.
completesIdentifies a tfo:Partial function that this tfo:Invocation completes.
tfo:Invocationtfo:PartialtransformSpecifies the transform associated with this particular invocation.
prov:usedtfo:Partialtfo:FunctioninputSpecifies the resource that was the input of the transformation function.
prov:usedtfo:Invocationrdfs:ResourceoutputSpecifies the resource that was the output of the transformation function.
tfo:Invocationrdfs:ResourceIn certain contexts it is useful to pre-declare constraints on what constitutes valid input for a transform. We can do this either by URI or by XPath.
by-uriSpecifies a regular expression for matching against URIs.
tfo:Functiontfo:regexpnot-by-uriSpecifies a regular expression for anti-matching against URIs.
tfo:Functiontfo:regexpprefixSpecifies a SHACL prefix declaration for complementing any associated XPath expression.
tfo:MarkupTransformsh:PrefixDeclarationby-xpathSpecifies an XPath expression for matching against markup (HTML/XML) content.
tfo:MarkupTransformtfo:xpathnot-by-xpathSpecifies an XPath expression for anti-matching against markup (HTML/XML) content.
tfo:MarkupTransformtfo:xpathCurrently there is only the datatype for designating content types, and those for regular expressions and XPath.
content-typeA literal that represents a content-type such as that which is found in the HTTP Accept: or Content-Type: header.
xsd:token matching ^([!#$%&'\*\+\-.^_`|~0-9-A-Za-z]+)(?:/[!#$%&'\*\+\-.^_`|~0-9-A-Za-z]+)?)$ regexpA regular expression.
xsd:stringiregexpA case-insensitive regular expression.
tfo:regexpxsd:stringtermAn RDF term represented as either a CURIE (prefixed term) or IRI.
xsd:QName ∪ xsd:anyURI)xpathAn XPath expression.
xsd:string