Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
add document as naked properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Hsiao Su authored and Hsiao Su committed Dec 3, 2010
1 parent 34d18c9 commit d66e192
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/xquery/insert-tuples.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ xquery version "1.0-ml";
import module namespace sem="http://marklogic.com/semantic"
at "semantic.xqy";

declare variable $AS-PROPERTY as xs:boolean external ;

declare variable $FOREST as xs:unsignedLong external
;
declare variable $MAP as map:map external
;

for $n as element(t) in map:get($MAP, xs:string($FOREST))
return sem:tuple-insert($n/s, $n/p, $n/o, $n/c)
if ($AS-PROPERTY)
then sem:tuple-insert-as-property(map:get($MAP, xs:string($FOREST)))
else sem:tuple-insert(map:get($MAP, xs:string($FOREST)))

(: insert-tuples.xqy :)
3 changes: 2 additions & 1 deletion src/xquery/insert.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ for $key in map:keys($MAP)
let $forest := xs:unsignedLong($key)
return xdmp:invoke(
'insert-tuples.xqy',
(xs:QName('FOREST'), $forest,
(xs:QName('AS-PROPERTY'), true(),
xs:QName('FOREST'), $forest,
xs:QName('MAP'), $MAP),
<options xmlns="xdmp:eval">{
element database { $forest } }</options> )
Expand Down
21 changes: 21 additions & 0 deletions src/xquery/semantic.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,27 @@ as element(t)
}
};

declare function sem:tuple-insert-as-property(
$s as xs:string,
$p as xs:string,
$o as xs:string,
$c as xs:string?)
as empty-sequence()
{
xdmp:document-add-properties(
sem:uri-for-tuple($s, $p, $o, $c),
sem:tuple($s, $p, $o, $c)/* )
};

declare function sem:tuple-insert-as-property(
$t as element(t))
as empty-sequence()
{
xdmp:document-add-properties(
sem:uri-for-tuple($t/s, $t/p, $t/o, $t/c),
sem:tuple($t/s, $t/p, $t/o, $t/c)/* )
};

declare function sem:tuple-insert(
$s as xs:string,
$p as xs:string,
Expand Down

0 comments on commit d66e192

Please sign in to comment.