
sem.queryResultsSerialize( results as option, [options as String[]] ) as queryResultsSerialize($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'. |
const sem = require("/MarkLogic/semantics.xqy");
sem.queryResultsSerialize(sem.sparql(
'PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\
SELECT ?name WHERE { ?alum foaf:schoolHomepage <http://www.ucsb.edu/> .\n\
?alum foaf:knows ?person .\n\
?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.