Documentation ¶
Overview ¶
Example (Example1) ¶
package main import ( "embed" "fmt" _ "embed" ttl "github.com/0x51-dev/rdf/turtle" ) var example1 string func main() { doc, _ := ttl.ParseDocument(example1) fmt.Println(doc) }
Output: @base <http://example.org/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix rel: <http://www.perceive.net/schemas/relationship/> . <#green-goblin> a foaf:Person ; foaf:name "Green Goblin" ; rel:enemyOf <#spiderman> . <#spiderman> a foaf:Person ; foaf:name "Spiderman", "Человек-паук"@ru ; rel:enemyOf <#green-goblin> .
Index ¶
- func EvaluateDocument(doc Document, cwd string) (nt.Document, error)
- func ValidateDocument(doc Document) bool
- type A
- type Base
- type BlankNode
- type BlankNodePropertyList
- type BooleanLiteral
- type Collection
- type Context
- func (ctx *Context) EvaluateBlankNodePropertyList(pl BlankNodePropertyList) ([]nt.Object, []nt.Triple, error)
- func (ctx *Context) EvaluateBooleanLiteral(o *BooleanLiteral) (*nt.Literal, error)
- func (ctx *Context) EvaluateCollection(c Collection) (nt.Object, []nt.Triple, error)
- func (ctx *Context) EvaluateIRI(iri *IRI) (*nt.IRIReference, error)
- func (ctx *Context) EvaluateNumericLiteral(o *NumericLiteral) (*nt.Literal, error)
- func (ctx *Context) EvaluateObject(o Object) ([]nt.Object, []nt.Triple, error)
- func (ctx *Context) EvaluateObjectList(os ObjectList) ([]nt.Object, []nt.Triple, error)
- func (ctx *Context) EvaluatePredicateObject(po PredicateObject) (nt.IRIReference, []nt.Object, []nt.Triple, error)
- func (ctx *Context) EvaluateStringLiteral(o *StringLiteral) (*nt.Literal, error)
- func (ctx *Context) EvaluateTriple(t *Triple) ([]nt.Triple, error)
- func (ctx *Context) ValidateCollection(c Collection) bool
- func (ctx *Context) ValidateIRI(i *IRI) bool
- func (ctx *Context) ValidatePredicateObjectList(p PredicateObjectList) bool
- func (ctx *Context) ValidateTriple(t *Triple) bool
- type Directive
- type Document
- type IRI
- type Literal
- func ParseBooleanLiteral(n *parser.Node) (Literal, error)
- func ParseDecimal(n *parser.Node) (Literal, error)
- func ParseDouble(n *parser.Node) (Literal, error)
- func ParseInteger(n *parser.Node) (Literal, error)
- func ParseLiteral(n *parser.Node) (Literal, error)
- func ParseNumericLiteral(n *parser.Node) (Literal, error)
- func ParseRDFLiteral(n *parser.Node) (Literal, error)
- type NumericLiteral
- type NumericType
- type Object
- type ObjectList
- type PredicateObject
- type PredicateObjectList
- type Prefix
- type Statement
- type StringLiteral
- type Subject
- type Triple
- type Verb
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateDocument ¶
Types ¶
type BlankNodePropertyList ¶
type BlankNodePropertyList PredicateObjectList
BlankNodePropertyList may appear in the subject or object position of a triple. That subject or object is a fresh RDF blank node. This blank node also serves as the subject of the triples produced by matching the predicateObjectList production embedded in a blankNodePropertyList.
func ParseBlankNodePropertyList ¶
func ParseBlankNodePropertyList(n *parser.Node) (BlankNodePropertyList, error)
func (BlankNodePropertyList) Equal ¶
func (b BlankNodePropertyList) Equal(v any) bool
func (BlankNodePropertyList) String ¶
func (b BlankNodePropertyList) String() string
type BooleanLiteral ¶
type BooleanLiteral bool
func (BooleanLiteral) Equal ¶
func (bl BooleanLiteral) Equal(v any) bool
func (BooleanLiteral) String ¶
func (bl BooleanLiteral) String() string
type Collection ¶
type Collection []Object
Collection represents a rdf:first/rdf:rest list structure with the sequence of objects of the rdf:first statements being the order of the terms enclosed by (). It appears in the subject or object position of a triple. The blank node at the head of the list is the subject or object of the containing triple.
func ParseCollection ¶
func ParseCollection(n *parser.Node) (Collection, error)
func (Collection) Equal ¶
func (c Collection) Equal(v any) bool
func (Collection) String ¶
func (c Collection) String() string
type Context ¶
func NewContext ¶
func NewContext() *Context
func (*Context) EvaluateBlankNodePropertyList ¶
func (*Context) EvaluateBooleanLiteral ¶
func (ctx *Context) EvaluateBooleanLiteral(o *BooleanLiteral) (*nt.Literal, error)
func (*Context) EvaluateCollection ¶
func (*Context) EvaluateIRI ¶
func (ctx *Context) EvaluateIRI(iri *IRI) (*nt.IRIReference, error)
func (*Context) EvaluateNumericLiteral ¶
func (ctx *Context) EvaluateNumericLiteral(o *NumericLiteral) (*nt.Literal, error)
func (*Context) EvaluateObject ¶
func (*Context) EvaluateObjectList ¶
EvaluateObjectList evaluates a list of objects.
func (*Context) EvaluatePredicateObject ¶
func (ctx *Context) EvaluatePredicateObject(po PredicateObject) (nt.IRIReference, []nt.Object, []nt.Triple, error)
func (*Context) EvaluateStringLiteral ¶
func (ctx *Context) EvaluateStringLiteral(o *StringLiteral) (*nt.Literal, error)
func (*Context) ValidateCollection ¶
func (ctx *Context) ValidateCollection(c Collection) bool
func (*Context) ValidateIRI ¶
func (*Context) ValidatePredicateObjectList ¶
func (ctx *Context) ValidatePredicateObjectList(p PredicateObjectList) bool
func (*Context) ValidateTriple ¶
type Directive ¶
type Literal ¶
type Literal interface { Object Equal(v any) bool fmt.Stringer // contains filtered or unexported methods }
Literal is either StringLiteral, NumericLiteral or BooleanLiteral.
type NumericLiteral ¶
type NumericLiteral struct { Type NumericType Value string }
func (NumericLiteral) Equal ¶
func (nl NumericLiteral) Equal(v any) bool
func (NumericLiteral) String ¶
func (nl NumericLiteral) String() string
type ObjectList ¶
type ObjectList Collection
ObjectList matches a series of objects separated by ',' following a predicate. This expresses a series of RDF Triples with the corresponding subject and predicate and each object allocated to one triple.
func ParseObjectList ¶
func ParseObjectList(n *parser.Node) (ObjectList, error)
func (ObjectList) Equal ¶
func (ol ObjectList) Equal(v any) bool
func (ObjectList) Len ¶
func (ol ObjectList) Len() int
func (ObjectList) Less ¶
func (ol ObjectList) Less(i, j int) bool
func (ObjectList) String ¶
func (ol ObjectList) String() string
func (ObjectList) Swap ¶
func (ol ObjectList) Swap(i, j int)
type PredicateObject ¶
type PredicateObject struct { Verb Verb ObjectList ObjectList }
func ParsePredicateObject ¶
func ParsePredicateObject(n *parser.Node) (*PredicateObject, error)
func (PredicateObject) Equal ¶
func (po PredicateObject) Equal(v any) bool
func (PredicateObject) String ¶
func (po PredicateObject) String() string
type PredicateObjectList ¶
type PredicateObjectList []PredicateObject
PredicateObjectList matches a series of predicates and objects, separated by ';', following a subject. This expresses a series of RDF Triples with that subject and each predicate and object allocated to one triple.
func ParsePredicateObjectList ¶
func ParsePredicateObjectList(n *parser.Node) (PredicateObjectList, error)
func (PredicateObjectList) Equal ¶
func (pol PredicateObjectList) Equal(v any) bool
func (PredicateObjectList) Len ¶
func (pol PredicateObjectList) Len() int
func (PredicateObjectList) Less ¶
func (pol PredicateObjectList) Less(i, j int) bool
func (PredicateObjectList) String ¶
func (pol PredicateObjectList) String() string
func (PredicateObjectList) Swap ¶
func (pol PredicateObjectList) Swap(i, j int)
type StringLiteral ¶
type StringLiteral struct { Value string Multiline bool SingleQuote bool LanguageTag string DatatypeIRI *IRI }
func ParseStringLiteral ¶
func ParseStringLiteral(n *parser.Node) (*StringLiteral, error)
func (StringLiteral) Equal ¶
func (sl StringLiteral) Equal(v any) bool
func (StringLiteral) String ¶
func (sl StringLiteral) String() string
type Subject ¶
type Triple ¶
type Triple struct { Subject Subject BlankNodePropertyList BlankNodePropertyList PredicateObjectList PredicateObjectList }
func (Triple) PredicateObjectMap ¶
func (t Triple) PredicateObjectMap() (map[string]ObjectList, error)