HI.

Yeah.  But I keep them tidy together inside andother element.

Here is a little example (run twice in query console to see the result).
Also, you don't necessarily need the subject to be the uri of the doc as
you can already isolate on fragments, but I do it so that I can use them in
sparql queries naturally.


xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";;

import module namespace sem = "http://marklogic.com/semantics";
   at "MarkLogic/semantics.xqy";


let $uri := "/semantic-test/doc.xml"
let $triple := sem:triple(sem:iri($uri), sem:iri("likes"), "tomatos")

let $update := if(fn:boolean(xdmp:document-properties($uri)//semantics))
  then xdmp:document-set-property($uri,
xdmp:node-insert-child(xdmp:document-properties($uri)//semantics,
<xml>{$triple}</xml>/*))
  else xdmp:document-set-property($uri, <semantics>{$triple}</semantics>)


return sem:sparql('
  select $s
  where {$s $p "tomatos"}
')



Kind Regards,
David Ennis


David Ennis
*Content Engineer*

[image: HintTech]  <http://www.hinttech.com/>
Mastering the value of content
creative | technology | content

Delftechpark 37i
2628 XJ Delft
The Netherlands
T: +31 88 268 25 00
M: +31 63 091 72 80

[image: http://www.hinttech.com] <http://www.hinttech.com>
<https://twitter.com/HintTech>  <http://www.facebook.com/HintTech>
<http://www.linkedin.com/company/HintTech>

On 24 December 2014 at 23:12, Alex Jouravlev <al...@businessabstraction.com>
wrote:

> Hi David,
>
>
>
> Do you mean you use xdmp:document-set-properties and
> xdmp:document-add-properties?
>
>
>
> Thank you,
>
>
>
> Alex Jouravlev
> Director, Business Abstraction Pty Ltd
> Phone:       +61-(2)-8003-4830
> Mobile:     +61-4-0408-3258
> Web: http://www.businessabstraction.com
> LinkedIn: http://au.linkedin.com/in/alexjouravlev/
>
> *From:* general-boun...@developer.marklogic.com [mailto:
> general-boun...@developer.marklogic.com] *On Behalf Of *David Ennis
> *Sent:* Tuesday, 23 December 2014 8:12 PM
> *To:* MarkLogic Developer Discussion
> *Subject:* Re: [MarkLogic Dev General] Inserting triples into a document
>
>
>
> Hi.
>
>
>
> You can store them anywhere in a document or properties fragment as long
> as they are in sem:triples format.
>
>
>
> http://docs.marklogic.com/sem:triple
>
>
>
> Its just an XML element of a certain namespace that causes it to be
> indexed as a triple.
>
>
>
> Example somewhere in your XML:
>
> <sem:triple xmlns:sem="http://marklogic.com/semantics";>
>
>   <sem:subject>subject</sem:subject>
>
>   <sem:predicate>predicate</sem:predicate>
>
>   <sem:object
>
>    datatype="http://www.w3.org/2001/XMLSchema#string";>object</sem:object>
>
> </sem:triple>
>
>
>
> I like to store them in properties fragments as I find it a bit tidy.
>
>
>
> Kind Regards,
>
> David Ennis
>
>
>
>
>
>
> Kind Regards,
>
> David Ennis
>
>
>
>
>
> *David Ennis*
> *Content Engineer*
>
> [image: HintTech]  <http://www.hinttech.com/>
> Mastering the value of content
> creative | technology | content
>
> Delftechpark 37i
> 2628 XJ Delft
> The Netherlands
> T: +31 88 268 25 00
> M: +31 63 091 72 80
>
> [image: http://www.hinttech.com] <http://www.hinttech.com>
> <https://twitter.com/HintTech>  <http://www.facebook.com/HintTech>
> <http://www.linkedin.com/company/HintTech>
>
>
>
> On 23 December 2014 at 08:12, Alex Jouravlev <
> al...@businessabstraction.com> wrote:
>
> Hi,
>
>
>
> Is it possible to insert triples into a given document? It doesn’t look
> like sem:rdf-insert does that. However some case studies suggest adding
> triples tro documents.
>
>
>
> Thanks
>
>
>
> Alex Jouravlev
> Mobile:     +61-4-0408-3258
> LinkedIn: http://au.linkedin.com/in/alexjouravlev/
>
>
>
>
> _______________________________________________
> General mailing list
> General@developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
>
>
>
> _______________________________________________
> General mailing list
> General@developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
>
>
_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to