N3Patch

data class N3Patch(val deletes: String? = null, val inserts: String? = null, val where: String? = null)

Represents a Solid N3 Patch document for use with HTTP PATCH requests.

A valid N3 Patch document declares rdf:type solid:InsertDeletePatch and may contain solid:deletes, solid:inserts, and solid:where formulae.

Building a patch

DSL builder — no raw N3 strings required:

// Simple insert
val patch = N3Patch.build {
insertLiteral(contactUri, VCARD.FN, "Alice")
}

// Safe replace — bind the old value via where, then swap it
val patch = N3Patch.build {
where(contactUri, VCARD.FN, variable = "oldName")
deleteVar(contactUri, VCARD.FN, variable = "oldName")
insertLiteral(contactUri, VCARD.FN, "Alice")
}

Diff factory — automatically derives the patch from two resource states:

val patch = N3Patch.fromDiff(originalResource, modifiedResource)

Content-Type: text/n3 Spec: https://solidproject.org/TR/protocol#n3-patch

Constructors

Link copied to clipboard
constructor(deletes: String? = null, inserts: String? = null, where: String? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The media type of an N3 Patch body: text/n3.

Link copied to clipboard

the triples to remove, as an N3 triple block, or null for none.

Link copied to clipboard

the triples to add, as an N3 triple block, or null for none.

Link copied to clipboard

an optional N3 graph pattern that binds variables used in deletes and inserts; required for value-dependent edits such as a safe replace.

Functions

Link copied to clipboard

Returns the toN3String document as a byte stream.

Link copied to clipboard

Serializes this patch to an N3 Patch document (text/n3).

Link copied to clipboard

Renders this patch as a SPARQL 1.1 Update document (application/sparql-update).