Skip to content

Commit

Permalink
Add a comprehensive list of RDF Media Types
Browse files Browse the repository at this point in the history
  • Loading branch information
bblfish committed Mar 18, 2021
1 parent 724ccfa commit 3dac359
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ lazy val root = project
"ch.qos.logback" % "logback-classic" % "1.2.3",
"org.typelevel" %% "cats-core" % "2.4.2",
"org.typelevel" %% "cats-free" % "2.4.2",
"net.bblfish.rdf" %% "banana-rdf" % "0.8.5-SNAPSHOT",
"net.bblfish.rdf" %% "banana-jena" % "0.8.5-SNAPSHOT",

//"com.novocode" % "junit-interface" % "0.11" % "test"
).map(_.withDottyCompat(scalaVersion.value)),
Expand Down
111 changes: 111 additions & 0 deletions src/main/scala/run/cosy/http/RDFMediaTypes.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package run.cosy.http

/**
* Media Types for RDF.
* Collected from the [[https://docs.aws.amazon.com/neptune/latest/userguide/sparql-media-type-support.html RDF media types used by SPARQL in Neptune]] document by Amazon.
* Feel free to complete the list if needed.
**/
object RDFMediaTypes {

import akka.http.scaladsl.model.MediaType
import akka.http.scaladsl.model.HttpCharsets.{`UTF-8`,`US-ASCII`}

/** see [[https://www.w3.org/TR/rdf-syntax-grammar/#section-MIME-Type RDF1.1 XML Syntax]] spec and
* [[https://tools.ietf.org/html/rfc3870 RFC3870]] registration
**/
val `application/rdf+xml` = MediaType.customWithOpenCharset(
"application","rdf+xml",
fileExtensions = List("rdf")
)

// Note that around 2004 the W3C defined a procedure for Mime Type Registration
// that uses the W3C specs without needing to go through an RFC procedure
// see [[https://www.w3.org/2020/01/registering-mediatypes.html Register and Internet Media Types for a W3C Spec]]

/** see [[https://www.w3.org/TR/n-triples/#n-triples-mediatype RDF 1.1 N-Triples]] spec. */
val `application/n-triples` = MediaType.customWithFixedCharset(
"application","n-triples",`UTF-8`,
fileExtensions = List("nt")
)
/**
* see [[https://www.w3.org/TR/n-quads/#sec-mediatype W3C NQuads Speec]]
* has IRI: http://www.w3.org/ns/formats/N-Quads
*/
val `application/n-quads` = MediaType.customWithFixedCharset(
"application","n-quads",`UTF-8`,
fileExtensions = List("nq")
)

/** The older version of n-quads was limited to US-ASCII and had a different mime type */
val `text/n-quads` = MediaType.customWithFixedCharset(
"text","n-quads",`US-ASCII`,
fileExtensions = List("nq")
)

/**
* see [[https://www.w3.org/TR/turtle/ RDF 1.1 Turtle]]
* has URI: http://www.w3.org/ns/formats/Turtle
*/
val `text/turtle` = MediaType.customWithFixedCharset(
"text","turtle",`UTF-8`,
fileExtensions = List("ttl")
)

/**
* see [[https://www.w3.org/TR/trig/#sec-mediaReg RDF1.1 TriG]]
*/
val `application/trig` = MediaType.customWithFixedCharset(
"application", "trig", `UTF-8`,
fileExtensions = List("trig")
)

/**
* see [[https://www.w3.org/TeamSubmission/n3/#sec-mediaReg Notation3 (N3): A readable RDF syntax]]
*/
val `text/n3` = MediaType.customWithFixedCharset(
"text","n3", `UTF-8`,
fileExtensions = "n3",
params =
)
/**
* see [[https://www.w3.org/TR/json-ld/#application-ld-json JSON-LD 1.1]]
* The JSON-LD spec defined six values for a profile parameter listed next.
*/
val `application/ld+json` = MediaType.customWithFixedCharset(
"application","ld+json",`UTF-8`,
fileExtensions = List("jsonld")
)

val jsonLdExpandedProfile = Uri("http://www.w3.org/ns/json-ld#expanded")
val jsonLdCompactedProfile = Uri("http://www.w3.org/ns/json-ld#compacted")
val jsonLdContextProfile = Uri("http://www.w3.org/ns/json-ld#context")
val jsonLdFlattenedProfile = Uri("http://www.w3.org/ns/json-ld#flattened")
val jsonLdFrameProfile = Uri("http://www.w3.org/ns/json-ld#frame")
val jsonLdFramedProfile = Uri("http://www.w3.org/ns/json-ld#framed")

/**
* Quad format defined by HP in XML
* [[https://www.hpl.hp.com/techreports/2004/HPL-2004-56.html]]
*/
val `application/trix` = MediaType.customWithOpenCharset(
"application","trix",
fileExtensions = List("trix")
)

/**
* see [[https://www.w3.org/TR/sparql11-results-json/#content-type SPARQL 1.1 Query Results JSON Format]]
*/
val `application/sparql-results+json` = MediaType.customWithFixedCharset(
"application","sparql-results+json",`UTF-8`,
fileExtensions = List("srj")
)

/**
* see [[https://www.w3.org/TR/rdf-sparql-XMLres/#mime SPARQL Query Results XML Format (Second Edition)]]
*/
val `application/sparql-results+xml` = MediaType.customWithOpenCharset(
"application","sparql-results+xml",
fileExtensions = List("srx")
)

}

0 comments on commit 3dac359

Please sign in to comment.