cts:从sem:SPARQL查询

时间:2019-11-08 21:26:37

标签: marklogic marklogic-9

如何从sem:sparql创建cts:query ...

背景,我要创建一个自定义约束,为此它需要返回cts:query ..但在我的自定义约束中,我想做sparql ..我该怎么做。 例如:

/*Constant*/
define("STRING_END", 7);

/*This functions prints two domino tiles; it's not really part of the question.*/
    function printTiles($left, $right){
        echo "<img src='".$left."_.png'/>", "<img src='_".$right.".png'/>";
    }

    /* Main Algorithm */
    $text = "1,2,4,4,4,6,7"; //the goal is to check if every two elements of the string are the same
    $arrayedText= explode(",", $text); //now I have the array with all the numbers from the string

    $doubleTiles = false; //this is just to check when double tiles have been found

    while ($arrayedText[1] != STRING_END){ //so while the next position is not a "7"
        $firstTile = array_shift($arrayedText); //the first tile is the first element of the array
        $nextTile = $arrayedText[0];        //the next tile is the "new" first element of the array after having removed the other one
        if($firstTile == $nextTile){ //if these two tiles are the same
            $doubleTiles = true; 
            printTiles($firstTile, $nextTile); //run the function and print the tiles on screen
        }
    }

1 个答案:

答案 0 :(得分:0)

我想我知道..需要使用cts:triple-range-query

如果有人感兴趣..以下是我为上面的sparq做的..

  cts:and-query((cts:triple-range-query((), sem:iri('http://schemas.abbvienet.com/entity/target'), 
                                                              sem:iri('http://rdf.abbvienet.com/entity/ncbi/target/695')),
                                   cts:collection-query('http://rdf.abbvienet.com/entity/abbvie/biologic'))))

请告诉我是否有更好的方法:)?

相关问题