On this page:
write-sparql-nsmap
nsmap->sparql-string
write-statement-pattern
statement-pattern->string

14.4 SPARQL Formatting🔗ℹ

procedure

(write-sparql-nsmap val [out])  void?

  val : nsmap?
  out : output-port? = (current-output-port)

procedure

(nsmap->sparql-string val)  void?

  val : nsmap?
Write a nsmap? to the provided output port, or to a string. This string will use SPARQL syntax in the output.

Examples:
> (require rdf/core/io
           rdf/core/nsmap)
> (write-sparql-nsmap (make-common-nsmap))

PREFIX owl: <http://www.w3.org/2002/07/owl#>

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX dcterms: <http://purl.org/dc/terms/>

PREFIX dc: <http://purl.org/dc/elements/1.1/>

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

> (displayln
    (nsmap->sparql-string (make-common-nsmap)))

PREFIX owl: <http://www.w3.org/2002/07/owl#>

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX dcterms: <http://purl.org/dc/terms/>

PREFIX dc: <http://purl.org/dc/elements/1.1/>

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

procedure

(write-statement-pattern val [out])  void?

  val : statement-pattern?
  out : output-port? = (current-output-port)

procedure

(statement-pattern->string val)  string?

  val : statement-pattern?
Write a statement-pattern? to the provided output port, or to a string, in SPARQL syntax.