Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MarkLogic triple objects language

I'm in a tricky situation and I can't seem to find any information in the MarkLogic documentation about it. The problem I'm having is that I am using triples from different sources and they are using different ways of describing string objects (some are multilingual):

<http://subject1> <http://www.w3.org/2004/02/skos/core#prefLabel> "Object"^^xs:string .
<http://subject2> <http://www.w3.org/2004/02/skos/core#prefLabel> "Object"@en .

So when I do a cts:triples((), sem:iri("http://www.w3.org/2004/02/skos/core#prefLabel"), "Object") then I only get the first triple.

The question is, how do I make it ignore the language and return the two triples (if possible, without using sparql)?

like image 588
John Smith Avatar asked Dec 17 '14 13:12

John Smith


People also ask

What are triples in MarkLogic?

Triples that included as part of an XML or a JSON document and have an element node of sem:triple are called unmanaged triples, sometimes referred to as embedded triples. These unmanaged triples must be in the MarkLogic XML or JSON format defined in the schema for sem:triple ( semantics. xsd ).

What is CTS MarkLogic?

cts:element-geospatial-value-match. Returns values from the specified element geospatial value lexicon(s) that match the specified wildcard pattern. cts:element-geospatial-values. Returns values from the specified element geospatial value lexicon(s).

How is data stored in MarkLogic?

MarkLogic fuses together database internals, search-style indexing, and application server behaviors into a unified system. It uses XML and JSON documents as its data model, and stores the documents within a transactional repository.


1 Answers

Interestingly enough using "Object" like above didn't return results at all for me (using MarkLogic 7.0-4.1 on MacOS). Instead I had to use:

cts:triples((),(),(
  sem:unknown("Object", sem:iri("http://www.w3.org/2001/XMLSchemastring")),
  rdf:langString("Object", "en")
))

Here some longer piece of code that you can run in QConsole (run it against an empty database!) to better understand what is going on:

xquery version "1.0-ml";

import module namespace sem = "http://marklogic.com/semantics"
       at "/MarkLogic/semantics.xqy";
sem:rdf-insert(sem:rdf-parse('
@prefix xs:  <http://www.w3.org/2001/XMLSchema> .
<http://subject1> <http://www.w3.org/2004/02/skos/core#prefLabel> "Object"^^xs:string .
<http://subject2> <http://www.w3.org/2004/02/skos/core#prefLabel> "Object"@en .
', "turtle"))
;

'all triples:',
cts:triples((),(),()),

'all objects:',
for $triple in cts:triples((),(),())
return xdmp:describe(sem:triple-object($triple)),

'all object languages:',
for $triple in cts:triples((),(),())
return concat('"', sem:lang(sem:triple-object($triple)), '"'),

'results with "Object":',
cts:triples((),(),sem:iri("Object")),

'results with sem:unknown("Object", sem:iri("xs:string")):',
cts:triples((),(),sem:unknown("Object", sem:iri("xs:string"))),

'results with sem:unknown("Object", sem:iri("http://www.w3.org/2001/XMLSchemastring")):',
cts:triples((),(),sem:unknown("Object", sem:iri("http://www.w3.org/2001/XMLSchemastring"))),

'results with rdf:langString("Object", "en")',
cts:triples((),(),rdf:langString("Object", "en")),

'combined results:',
cts:triples((),(),(
  sem:unknown("Object", sem:iri("http://www.w3.org/2001/XMLSchemastring")),
  rdf:langString("Object", "en")
))

HTH!

like image 68
grtjn Avatar answered Oct 25 '22 13:10

grtjn