
sem:query-results-serialize( $results as option, [$options as xs:string*] ) as query-results-serialize($results)
This function implements the W3C SPARQL Query Results
format. Any value sequence returned by sem:sparql can
be passed into this function. The result will be the W3C SPARQL
Results format, in either XML or JSON format.
| Parameters | |
|---|---|
| results | The results of calling a SPARQL query. |
| options | One of 'xml' (default) or 'json'. |
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
sem:query-results-serialize(sem:sparql('
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name WHERE { ?alum foaf:schoolHomepage <http://www.ucsb.edu/> .
?alum foaf:knows ?person .
?person foaf:name ?name }
'))
=>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="name">
</variable>
</head>
<results>
<result>
<binding name="name">
<literal datatype="http://www.w3.org/2001/XMLSchema#string">
Karen Schouten
</literal>
</binding>
</result>
<result>
<binding name="name">
<literal datatype="http://www.w3.org/2001/XMLSchema#string">
Nick Aster
</literal>
</binding>
</result>
</results>
</sparql>
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.