Hi All,

I have a question about I think transactions.

I want to insert some rdf and then query the database, and I want to do this in 
a function so I can call the function and depending on if I have the data in 
Marklogic or not get the data as rdf and insert it.

But my problem is that the following code only returns result second time I 
call it.
I’m thankful for pointers here
Regards
Erik
Code below
==============================================

xquery version "1.0-ml" encoding "utf-8";


import module namespace sem = "http://marklogic.com/semantics";
      at "/MarkLogic/semantics.xqy";
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";;

let $wDataRdf :=
<rdf:RDF
                      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
                      xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#";

                      xmlns:wikibase="http://wikiba.se/ontology#";
                      xmlns:wd="http://www.wikidata.org/entity/";
                      >
    <rdf:Description rdf:about="http://www.wikidata.org/entity/Q925hhq";>
        <rdfs:label xml:lang="sv">mup</rdfs:label>
    </rdf:Description>

</rdf:RDF>
let $insert :=  xdmp:eval(
            '
            import module namespace sem = "http://marklogic.com/semantics";
      at "/MarkLogic/semantics.xqy";
            declare variable $wDataRdf as node() external;
            sem:rdf-insert(sem:rdf-parse($wDataRdf,("rdfxml", 
"graph=http://www.wikidata.org";)))'
            ,(xs:QName("wDataRdf"), $wDataRdf)
            )
return sem:sparql('
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?label WHERE {
   wd:Q925hhq  rdfs:label ?label
   FILTER (langMatches( lang(?label), "SV" ) )
}'
)



_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to