Skip to content

How to get string Literal serialized without quotation marks (") wrapping? #1974

Answered by niklasl
maciaren asked this question in Q&A
Discussion options

You must be logged in to vote

@maciaren I believe you actually do not want an RDF Literal, which are just datatyped/language-tagged scalar ("atomic") values. Those who do not have a syntactic shorthand in a certain serialization are always "just" a string, and in Turtle, quotes within those must be escaped. You cannot "break out of syntax" without hacking the serializer in non-standard ways.

What you appear to be wanting is to express an S-expression as an RDF List (formally called an RDF Collection). This is definitely possible. Programmatically you can build your desired Turtle example like this:

from rdflib import Graph, Namespace, Literal, BNode

CC = Namespace("https://example.org/cc/")
R = Namespace("https://exa…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@maciaren
Comment options

Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants