2014-12-17 24 views
5

Sono in una situazione difficile e non riesco a trovare alcuna informazione nella documentazione MarkLogic a riguardo. Il problema che sto avendo è che sto usando triple provenienti da fonti diverse e che stanno utilizzando diversi modi di descrivere oggetti stringa (alcuni sono multilingue):MarkLogic triple objects language

<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 . 

Così, quando faccio un cts:triples((), sem:iri("http://www.w3.org/2004/02/skos/core#prefLabel"), "Object") allora solo io ottieni la prima tripla.

La domanda è, come faccio a ignorare la lingua e restituire le due triple (se possibile, senza usare sparql)?

risposta

5

È interessante notare che utilizzare "Oggetto" come sopra non ha restituito risultati per me (utilizzando MarkLogic 7.0-4.1 su MacOS). Invece ho dovuto usare:

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

Ecco qualche pezzo più lungo di codice che è possibile eseguire in QConsole (lanciarlo contro un database vuoto!) Per capire meglio ciò che sta accadendo:

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 !