From 3623ca271ca73fc4daa0405f39ae5da9977b15e4 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Mon, 2 Jun 2014 15:12:29 +0200 Subject: getCollByName and getOutcomeFromEvent xquery functions --- src/main/resources/cristal-function-lib.xql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/main/resources/cristal-function-lib.xql b/src/main/resources/cristal-function-lib.xql index 273727f..3c6b6b3 100644 --- a/src/main/resources/cristal-function-lib.xql +++ b/src/main/resources/cristal-function-lib.xql @@ -13,4 +13,21 @@ declare function cristal:getCollByType($typeName as xs:string) as xs:string* let $prodType := collection($itemColl)/Property[@name="Type"] where $prop eq $typeName and $prodType eq "Product" return $itemColl +}; + +declare function cristal:getCollByName($name as xs:string) as xs:string* +{ + for $prop in //Property[@name="CfCName"] + let $itemColl := util:collection-name($prop) + let $prodType := collection($itemColl)/Property[@name="Type"] + where $prop eq $typeName and $prodType eq "Product" + return $itemColl +}; + +declare function cristal:getOutcomeFromEvent($coll as xs:string, $event as node()) as xs:string +{ + let $schemaName := $event/@SchemaName + let $schemaVersion := $event/@SchemaVersion + let $eventId := $event/@ID + return fn:string-join(($coll,'/','Outcome.',$schemaName,'.',$schemaVersion,'.',$eventId),'') }; \ No newline at end of file -- cgit v1.2.3