
sem.rdfSerialize( triples as sem.triple[], [options as String[]] ) as Item
This function returns a string or json or XML serialization of the provided triples.
const sem = require("/MarkLogic/semantics.xqy");
sem.rdfSerialize(
(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" .
const sem = require("/MarkLogic/semantics.xqy");
sem.rdfSerialize(
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.