MarkLogic 3D Object Language

I have a difficult situation, and I can not find any information in the MarkLogic documentation. The problem I am facing is that I use triples from different sources, and they use different ways to describe string objects (some of them 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 cts:triples((), sem:iri("http://www.w3.org/2004/02/skos/core#prefLabel"), "Object") then I get only the first three.

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

+5
source share
1 answer

Interestingly, using an “Object” like the one above did not give me any results at all (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 is a longer piece of code that you can run in QConsole (run it against an empty database!) To better understand what is happening:

 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") )) 

NTN!

+5
source

Source: https://habr.com/ru/post/1209355/


All Articles