package rdfwriter

import "github.com/spdx/gordf/rdfwriter"

Index

Functions

func DisjointSet

func DisjointSet(triples []*parser.Triple) map[*parser.Node]*parser.Node

func FilterTriples

func FilterTriples(triples []*parser.Triple, subject, predicate, object *string) (result []*parser.Triple)
returns the triples that matches the input subject, object and the predicate.

reason behind using string pointers is that it allows the user to pass a nil if the user is unsure about the other types. For example, if the user wants all the triples with subject rdf:about, the user can call FilterTriples(triples, &rdfAboutString, nil, nil) where, rdfAboutString := "rdf:about"

func GetAdjacencyList

func GetAdjacencyList(triples []*parser.Triple) (adjList map[*parser.Node][]*parser.Node)

returns an adjacency list from a list of triples Params:

triples: might be unordered

Output:

adjList: adjacency list which maps subject to object for each triple

func GetNodeToTriples

func GetNodeToTriples(triples []*parser.Triple) (recoveryDS map[string][]*parser.Triple)

Params:

triples: might be unordered

Output:

recoveryDS: subject to triple mapping that will help retrieve the
            triples after sorting the Subject: Object pairs.

func GetRootNodes

func GetRootNodes(triples []*parser.Triple) (rootNodes []*parser.Node)

from a given adjacency list, return a list of root-nodes which will be used to generate string forms of the nodes to be written.

func TopologicalSortTriples

func TopologicalSortTriples(triples []*parser.Triple) (sortedTriples []*parser.Triple, err error)

Interface for user to provide a list of triples and get the sorted one as the output

func TriplesToString

func TriplesToString(triples []*parser.Triple, schemaDefinition map[string]uri.URIRef, tab string) (outputString string, err error)

function provided to the user for converting triples to string. Arg Description:

triples: list of triples of a rdf graph
schemaDefinition: maps the prefix given by xmlns to the URI
tab: tab character to be used in the output. It can be four-spaces,
     two-spaces, single tab character, double tab character, etc
     depending upon the choice of the user.

func WriteToFile

func WriteToFile(w io.Writer, triples []*parser.Triple, schemaDefinition map[string]uri.URIRef, tab string) error

converts the input triples to string and writes it to the file. Args Description:

w: writer in which the output data will be written.
rest all params are same as that of the TriplesToString function.

Source Files

rdfwriter.go utils.go

Version
v0.0.0-20250128162952-000978ccd6fb (latest)
Published
Jan 28, 2025
Platform
linux/amd64
Imports
5 packages
Last checked
2 weeks ago

Tools for package owners.