
sem:rdf-serialize( $triples as sem:triple*, [$options as xs:string*] ) as item()
This function returns a string or json or XML serialization of the provided triples.
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
sem:rdf-serialize(
(sem:triple(
sem:iri("http://example.com/ns/directory#m"),
sem:iri("http://example.com/ns/person#firstName"), "Michelle")))
=>
<http://example.com/ns/directory#m>
<http://example.com/ns/person#firstName> "Michelle" .
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
sem:rdf-serialize(
sem:triple(sem:iri("http://example.com/ns/directory#m"),
sem:iri("http://example.com/ns/person#firstName"),
"Michelle"), "rdfxml")
=>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="http://example.com/ns/directory#m">
<firstName rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
xmlns="http://example.com/ns/person#">Michelle
</firstName>
</rdf:Description>
</rdf:RDF>
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.