An object can be any type of value -- it doesn't have to be an IRI. This might 
work:

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

sem:rdf-insert(
  (
    sem:triple(
      sem:iri("http://example.com/ns/blue/154397";),
      sem:iri("http://example.com/ns/rankset/1443192107";),
      141
  )
)


--
Dave Cassel<http://davidcassel.net>, @dmcassel<https://twitter.com/dmcassel>
Technical Community Manager
MarkLogic Corporation<http://www.marklogic.com/>
http://developer.marklogic.com/


From: 
<[email protected]<mailto:[email protected]>>
 on behalf of b <[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Tuesday, October 20, 2015 at 10:45 AM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] Specific data types in sam:triple

I’ve inserted a bunch of triples using code similar to this below.

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

sem:rdf-insert(
  (
  sem:triple(
sem:iri("http://example.com/ns/blue/154397";),
sem:iri("http://example.com/ns/rankset/1443192107";),
sem:iri("http://example.com/ns/rank/141";)
)

I change the document and the rank.

Now, I want to retrieve it using SPARQL

PREFIX rankset: <http://example.com/ns/rankset/<http://example/ns/timestamp/>>
SELECT ?doc ?rank
WHERE { ?doc rankset:1443192107 ?rank }
ORDER BY ASC(?rank)
LIMIT 250

And I get back things like this:


1       
{"doc":"<http://example.com/ns/document/blue/134215>","rank":"<http://example.com/ns/rank/1>"},
2       
{"doc":"<http://example.com/ns/document/blue/144461>","rank":"<http://example.com/ns/rank/10>"},
3       
{"doc":"<http://example.com/ns/document/blue/140087>","rank":"<http://example.com/ns/rank/100>"},
4       
{"doc":"<http://example.com/ns/document/blue/150452>","rank":"<http://example.com/ns/rank/10000>"},
5       
{"doc":"<http://example.com/ns/document/blue/136182>","rank":"<http://example.com/ns/rank/101>"},
6       
{"doc":"<http://example.com/ns/document/blue/144417>","rank":"<http://example.com/ns/rank/102>”}…


This is almost right.  My value for rank is being treated like a string so I’m 
getting a string sort on the value.  You can see this in line 5 and line 6 
coming after line 4 above.

Is there a way to coerce in SPARQL or should I correct the triple with some  
ata type declaration?  How would that change my XQuery example above?  I can’t 
find any examples of data types using the sem:triple.  I have seen some in pure 
inline XML.

Thank you

bek

_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to