I have a set of XQuery functions that represent various operations that can be executed to transform a data value. Each function will take a value(s), plus some parameters needed for the transformation. And the plan is to execute a series of nested function calls to compute the final value. The idea is these pipelines will be configured and then persisted prior to execution, since the same pipeline of functions will be called repeatedly with different starting values. So, the thought was to represent the call stack as a series of nested XML elements, i.e.
<mylib:escape>
<value>
<mylib:select>
<config>
<index>2</index>
</config>
<value>
<mylib:tokenize>
<config>
<delimiter>,</delimiter>
</config>
<value>
$starting-value
</value>
</mylib:tokenize>
</value>
</mylib:select>
</value>
</mylib:escape>
And in the mylib module namespace, I would have functions:
declare function mylib:tokenize($value as xs:string, $delimiter as xs:string) as xs:string
{ ... }
declare function mylib:select($value as xs:string, $index as xs:int) as xs:string
{ ... }
declare function mylib:escape($value as xs:string) as xs:string
{ ... }
- is this a bad idea, and should I take a different approach
- Is there an existing library that might already provide this functionality?
This post is tagged with MarkLogic because I am going to be executing this from MarkLogic.
Thanks.