blanknode

package module
v0.0.0-...-88616d2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 8 Imported by: 0

README

go-blanknode

Package blanknode provides tools for working with blank node identifiers and blank node labels, for the Go programming language.

Blank Node Identifiers and Blank Node Labels are used in RDF (resource description framework) technologies, such as: JSON-LD, N-Quads, N-Triples, RDF/XML, RDFa, TriG, Turtle, etc.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-blanknode

GoDoc

Import

To import package blanknode use import code like the following:

import "github.com/reiver/go-blanknode"

Installation

To install package blanknode do the following:

GOPROXY=direct go get github.com/reiver/go-blanknode

Author

Package blanknode was written by Charles Iliya Krempeaux

Documentation

Index

Constants

View Source
const (
	ErrIdentifierPrefixNotFound      = erorr.Error("blank-node-identifier prefix (\"_:\") not found")
	ErrLabelFirstCharacterNotAllowed = erorr.Error("blank-node-label first character not allowed")
	ErrLabelLastCharacterNotAllowed  = erorr.Error("blank-node-label last character not allowed")
	ErrEmptyIdentifier               = erorr.Error("empty blank-node-identifier")
	ErrEmptyLabel                    = erorr.Error("empty blank-node-label")
	ErrEmptyString                   = erorr.Error("empty string")
	ErrNilReceiver                   = erorr.Error("nil receiver")
)
View Source
const IdentifierPrefix string = "_:"

IdentifierPrefix is the prefix at the beginning of all blank-node-identifiers.

It makes blank-node-identifiers look like a URL/URI/IRI with a scheme of "_".

You can see the prefix in these example blank-node-identifiers:

_:b0
_:address84
_:n1
_:ed7ba470-8e54-465e-825c-99712043e01c
_:label123

Variables

This section is empty.

Functions

func HasIdentifierPrefix

func HasIdentifierPrefix(value string) bool

HasIdentifierPrefix return whether a string beings with a "_:" or not.

All blank-node-identifiers begin with a "_:".

Types

type Identifier

type Identifier struct {
	// contains filtered or unexported fields
}

Identifier represents a blank-node-identifier from RDF (resource description framework) technologies, such as: JSON-LD, N-Quads, N-Triples, RDF/XML, RDFa, TriG, Turtle, etc.

Here are some example blank-node-identifiers:

_:b0
_:address84
_:n1
_:ed7ba470-8e54-465e-825c-99712043e01c
_:label123

func MustParseIdentifierBytes

func MustParseIdentifierBytes(value []byte) Identifier

func MustParseIdentifierString

func MustParseIdentifierString(value string) Identifier

func NoIdentifier

func NoIdentifier() Identifier

NoLIdentifier returns an empty Identifier.

Identifier is an optional-type — also known as a option-type or maybe-type elsewhere.

func ParseIdentifierBytes

func ParseIdentifierBytes(value []byte) (Identifier, error)

ParseIdentifierBytes parses the []byte for a Blank Node Identifier.

A Blank Node Identifier looks like these:

_:b0
_:address84
_:n1
_:ed7ba470-8e54-465e-825c-99712043e01c
_:label123

func ParseIdentifierString

func ParseIdentifierString(value string) (Identifier, error)

ParseIdentifierString parses the string for a Blank Node Identifier.

A Blank Node Identifier looks like these:

_:b0
_:address84
_:n1
_:ed7ba470-8e54-465e-825c-99712043e01c
_:label123

func (Identifier) Get

func (receiver Identifier) Get() (string, bool)

func (Identifier) IsNothing

func (receiver Identifier) IsNothing() bool

func (Identifier) Label

func (receiver Identifier) Label() (Label, bool)

Label returns the blank-node-label for the blank-node-identifier.

func (Identifier) MarshalText

func (receiver Identifier) MarshalText() (text []byte, err error)

MarshalText makes Identifier fit encoding.TextMarshaler.

func (Identifier) String

func (receiver Identifier) String() string

String makes Identifier fit fmt.Stringer.

func (*Identifier) UnmarshalText

func (receiver *Identifier) UnmarshalText(text []byte) error

UnmarshalText makes Identifier fit encoding.TextUnmarshaler.

type Label

type Label struct {
	// contains filtered or unexported fields
}

Label represents a blank-node-label from RDF (resource description framework) technologies, such as: JSON-LD, N-Quads, N-Triples, RDF/XML, RDFa, TriG, Turtle, etc.

For each of the Blank Node Identifiers:

_:b0
_:address84
_:n1
_:ed7ba470-8e54-465e-825c-99712043e01c
_:label123

Their Blank Node Labels are as follows:

b0
address84
n1
ed7ba470-8e54-465e-825c-99712043e01c
label123

I.e., a Blank Node Label is the part of the Blank Node Identifier after the "_:".

func MustParseLabelBytes

func MustParseLabelBytes(value []byte) Label

func MustParseLabelString

func MustParseLabelString(value string) Label

func NoLabel

func NoLabel() Label

NoLabel returns an empty Label.

Label is an optional-type — also known as a option-type or maybe-type elsewhere.

func ParseLabelBytes

func ParseLabelBytes(value []byte) (Label, error)

ParseLabelBytes parses a []byte for a blank-node-label from RDF (resource description framework) technologies, such as: JSON-LD, N-Quads, N-Triples, RDF/XML, RDFa, TriG, Turtle, etc.

A blank-node-label is what comes after the "_:" is a blank-node-identifier.

For example, if the blank-node-identifier is:

_:abcdef12345

Then its blank-node-label is:

abcdef12345

This uses the definition found in RDF 1.1 Turtle (https://www.w3.org/TR/turtle/):

RDF blank nodes in Turtle are expressed as _: followed by a blank node label which is a series of name characters.
The characters in the label are built upon PN_CHARS_BASE, liberalized as follows:

• The characters _ and digits may appear anywhere in a blank node label.
• The character . may appear anywhere except the first or last character.
• The characters -, U+00B7, U+0300 to U+036F and U+203F to U+2040 are permitted anywhere except the first character.

( https://www.w3.org/TR/turtle/#BNodes )

Where, PN_CHARS_BASE is defined as:

PN_CHARS_BASE ::= [A-Z]           |
                  [a-z]           |
                  [#x00C0-#x00D6] |
                  [#x00D8-#x00F6] |
                  [#x00F8-#x02FF] |
                  [#x0370-#x037D] |
                  [#x037F-#x1FFF] |
                  [#x200C-#x200D] |
                  [#x2070-#x218F] |
                  [#x2C00-#x2FEF] |
                  [#x3001-#xD7FF] |
                  [#xF900-#xFDCF] |
                  [#xFDF0-#xFFFD] |
                  [#x10000-#xEFFFF]

( https://www.w3.org/TR/turtle/#grammar-production-PN_CHARS_BASE )

See also: ParseLabelString.

func ParseLabelString

func ParseLabelString(value string) (Label, error)

ParseLabelString parses a string for a blank-node-label from RDF (resource description framework) technologies, such as: JSON-LD, N-Quads, N-Triples, RDF/XML, RDFa, TriG, Turtle, etc.

A blank-node-label is what comes after the "_:" is a blank-node-identifier.

For example, if the blank-node-identifier is:

_:abcdef12345

Then its blank-node-label is:

abcdef12345

This uses the definition found in RDF 1.1 Turtle (https://www.w3.org/TR/turtle/):

 RDF blank nodes in Turtle are expressed as _: followed by a blank node label which is a series of name characters.
The characters in the label are built upon PN_CHARS_BASE, liberalized as follows:

• The characters _ and digits may appear anywhere in a blank node label.
• The character . may appear anywhere except the first or last character.
• The characters -, U+00B7, U+0300 to U+036F and U+203F to U+2040 are permitted anywhere except the first character.

( https://www.w3.org/TR/turtle/#BNodes )

Where, PN_CHARS_BASE is defined as:

PN_CHARS_BASE ::= [A-Z]           |
                  [a-z]           |
                  [#x00C0-#x00D6] |
                  [#x00D8-#x00F6] |
                  [#x00F8-#x02FF] |
                  [#x0370-#x037D] |
                  [#x037F-#x1FFF] |
                  [#x200C-#x200D] |
                  [#x2070-#x218F] |
                  [#x2C00-#x2FEF] |
                  [#x3001-#xD7FF] |
                  [#xF900-#xFDCF] |
                  [#xFDF0-#xFFFD] |
                  [#x10000-#xEFFFF]

( https://www.w3.org/TR/turtle/#grammar-production-PN_CHARS_BASE )

See also: ParseLabelString.

func (Label) Get

func (receiver Label) Get() (string, bool)

func (Label) IsNothing

func (receiver Label) IsNothing() bool

func (Label) MarshalText

func (receiver Label) MarshalText() (text []byte, err error)

MarshalText makes Label fit encoding.TextMarshaler.

func (Label) String

func (receiver Label) String() string

String makes Label fit fmt.Stringer.

func (*Label) UnmarshalText

func (receiver *Label) UnmarshalText(text []byte) error

UnmarshalText makes Label fit encoding.TextUnmarshaler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL