Documentation
¶
Index ¶
- Variables
- func AreGraphsIsomorphic(expected, actual []*Triple) bool
- func AreQuadsIsomorphic(expected, actual []*Quad) bool
- func DecodeFloat64BigEndian(buf []byte) float64
- func DecodeInt64BigEndian(buf []byte) int64
- func EncodeFloat64BigEndian(value float64) []byte
- func EncodeInt64BigEndian(value int64) []byte
- func GetSupportedContentTypes() []string
- func SerializeQuadsCanonical(quads []*Quad) string
- func SerializeTriplesCanonical(triples []*Triple) string
- type BlankNode
- type DefaultGraph
- type JSONLDIOParser
- type JSONLDParser
- type Literal
- func NewBooleanLiteral(value bool) *Literal
- func NewDateTimeLiteral(value time.Time) *Literal
- func NewDecimalLiteral(value float64) *Literal
- func NewDoubleLiteral(value float64) *Literal
- func NewIntegerLiteral(value int64) *Literal
- func NewLiteral(value string) *Literal
- func NewLiteralWithDatatype(value string, datatype *NamedNode) *Literal
- func NewLiteralWithLanguage(value, language string) *Literal
- func NewLiteralWithLanguageAndDirection(value, language, direction string) *Literal
- type NQuadsIOParser
- type NQuadsParser
- type NTriplesIOParser
- type NamedNode
- type Quad
- type QuotedTriple
- type RDFParser
- type RDFXMLIOParser
- type RDFXMLParser
- type ReifiedTriple
- type Term
- type TermType
- type TriGIOParser
- type TriGParser
- type Triple
- type TripleTerm
- type TurtleIOParser
- type TurtleParser
Constants ¶
This section is empty.
Variables ¶
var ( XSDString = NewNamedNode("http://www.w3.org/2001/XMLSchema#string") XSDInteger = NewNamedNode("http://www.w3.org/2001/XMLSchema#integer") XSDDecimal = NewNamedNode("http://www.w3.org/2001/XMLSchema#decimal") XSDFloat = NewNamedNode("http://www.w3.org/2001/XMLSchema#float") XSDDouble = NewNamedNode("http://www.w3.org/2001/XMLSchema#double") XSDBoolean = NewNamedNode("http://www.w3.org/2001/XMLSchema#boolean") XSDDateTime = NewNamedNode("http://www.w3.org/2001/XMLSchema#dateTime") XSDDate = NewNamedNode("http://www.w3.org/2001/XMLSchema#date") XSDTime = NewNamedNode("http://www.w3.org/2001/XMLSchema#time") XSDDuration = NewNamedNode("http://www.w3.org/2001/XMLSchema#duration") )
Helper functions for common XSD datatypes
var ( RDFDirLangString = NewNamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString") RDFReifies = NewNamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies") )
RDF 1.2 vocabulary constants
Functions ¶
func AreGraphsIsomorphic ¶
AreGraphsIsomorphic checks if two sets of triples are isomorphic, accounting for blank node label differences. Two graphs are isomorphic if there exists a bijection between their blank nodes such that when applied, the graphs are identical.
func AreQuadsIsomorphic ¶
AreQuadsIsomorphic checks if two sets of quads are isomorphic, accounting for blank node label differences in both triples and graph names.
func DecodeFloat64BigEndian ¶
func DecodeInt64BigEndian ¶
func EncodeFloat64BigEndian ¶
func EncodeInt64BigEndian ¶
Utility functions for encoding numeric values
func GetSupportedContentTypes ¶
func GetSupportedContentTypes() []string
GetSupportedContentTypes returns a list of all supported content types
func SerializeQuadsCanonical ¶
SerializeQuadsCanonical serializes quads to canonical N-Quads format (C14N) Implements RDF 1.2 canonicalization rules (escape sequences, whitespace) Note: Canonical form specifies representation, NOT ordering. Input order is preserved.
func SerializeTriplesCanonical ¶
SerializeTriplesCanonical serializes triples to canonical N-Triples format (C14N) Implements RDF 1.2 canonicalization rules (escape sequences, whitespace) Note: Canonical form specifies representation, NOT ordering. Input order is preserved.
Types ¶
type BlankNode ¶
type BlankNode struct {
ID string
}
BlankNode represents a blank node
func NewBlankNode ¶
type DefaultGraph ¶
type DefaultGraph struct{}
DefaultGraph represents the default graph
func NewDefaultGraph ¶
func NewDefaultGraph() *DefaultGraph
func (*DefaultGraph) Equals ¶
func (d *DefaultGraph) Equals(other Term) bool
func (*DefaultGraph) String ¶
func (d *DefaultGraph) String() string
func (*DefaultGraph) Type ¶
func (d *DefaultGraph) Type() TermType
type JSONLDIOParser ¶
type JSONLDIOParser struct{}
JSONLDIOParser parses JSON-LD format (triples, default graph)
func (*JSONLDIOParser) ContentType ¶
func (p *JSONLDIOParser) ContentType() string
type JSONLDParser ¶
type JSONLDParser struct{}
JSONLDParser parses JSON-LD format Note: This is a simplified parser that handles common JSON-LD patterns. It supports: - Simple @id and @type - Properties with string values - Properties with @value objects - Properties with @id references - @language and @type in value objects - Basic @context expansion (prefix mapping)
Not yet supported: - Full @context processing (remote contexts, nested contexts) - @graph - @list and @set - @reverse - Framing - Compaction/Expansion algorithms
func NewJSONLDParser ¶
func NewJSONLDParser() *JSONLDParser
NewJSONLDParser creates a new JSON-LD parser
type Literal ¶
type Literal struct {
Value string
Language string // for language-tagged strings
Direction string // RDF 1.2: text direction ("ltr", "rtl", or "")
Datatype *NamedNode // for typed literals
}
Literal represents an RDF literal
func NewBooleanLiteral ¶
func NewDateTimeLiteral ¶
func NewDecimalLiteral ¶
func NewDoubleLiteral ¶
func NewIntegerLiteral ¶
func NewLiteral ¶
func NewLiteralWithDatatype ¶
func NewLiteralWithLanguage ¶
func NewLiteralWithLanguageAndDirection ¶
NewLiteralWithLanguageAndDirection creates a literal with language and direction (RDF 1.2)
type NQuadsIOParser ¶
type NQuadsIOParser struct{}
NQuadsIOParser parses N-Quads format (quads with optional graph)
func (*NQuadsIOParser) ContentType ¶
func (p *NQuadsIOParser) ContentType() string
type NQuadsParser ¶
type NQuadsParser struct {
// contains filtered or unexported fields
}
NQuadsParser is an N-Quads parser that extends N-Triples with an optional 4th position for graphs N-Quads format: <subject> <predicate> <object> [<graph>] . Compatible with N-Triples (3 positions) - defaults to default graph
func NewNQuadsParser ¶
func NewNQuadsParser(input string) *NQuadsParser
NewNQuadsParser creates a new N-Quads parser with strict validation
func (*NQuadsParser) Parse ¶
func (p *NQuadsParser) Parse() ([]*Quad, error)
Parse parses the N-Quads document and returns quads
type NTriplesIOParser ¶
type NTriplesIOParser struct{}
NTriplesIOParser parses N-Triples format (triples only, default graph)
func (*NTriplesIOParser) ContentType ¶
func (p *NTriplesIOParser) ContentType() string
type NamedNode ¶
type NamedNode struct {
IRI string
}
NamedNode represents an IRI
func NewNamedNode ¶
type QuotedTriple ¶
QuotedTriple represents an RDF 1.2 quoted triple (triple term) Can be used as subject or object in other triples
func NewQuotedTriple ¶
func NewQuotedTriple(subject, predicate, object Term) (*QuotedTriple, error)
NewQuotedTriple creates a new quoted triple with validation
func (*QuotedTriple) Equals ¶
func (q *QuotedTriple) Equals(other Term) bool
func (*QuotedTriple) String ¶
func (q *QuotedTriple) String() string
func (*QuotedTriple) Type ¶
func (q *QuotedTriple) Type() TermType
type RDFParser ¶
type RDFParser interface {
// Parse parses RDF data from a reader and returns quads
Parse(reader io.Reader) ([]*Quad, error)
// ContentType returns the MIME type this parser handles
ContentType() string
}
RDFParser is the interface for parsing RDF data in various formats
type RDFXMLIOParser ¶
type RDFXMLIOParser struct{}
RDFXMLIOParser parses RDF/XML format (triples, default graph)
func (*RDFXMLIOParser) ContentType ¶
func (p *RDFXMLIOParser) ContentType() string
type RDFXMLParser ¶
type RDFXMLParser struct {
// contains filtered or unexported fields
}
RDFXMLParser parses RDF/XML format Note: This is a simplified parser that handles common RDF/XML patterns. It supports: - rdf:Description elements - Properties as XML elements - rdf:about, rdf:resource, rdf:ID, rdf:nodeID attributes - rdf:datatype, xml:lang attributes - Nested blank nodes - RDF containers (rdf:Bag, rdf:Seq, rdf:Alt) - rdf:li auto-numbering - xml:base for base URI resolution
Not yet supported: - rdf:parseType="Collection"
func NewRDFXMLParser ¶
func NewRDFXMLParser() *RDFXMLParser
NewRDFXMLParser creates a new RDF/XML parser
func (*RDFXMLParser) Parse ¶
func (p *RDFXMLParser) Parse(reader io.Reader) ([]*Quad, error)
Parse parses RDF/XML and returns quads (all in default graph)
func (*RDFXMLParser) SetBaseURI ¶
func (p *RDFXMLParser) SetBaseURI(base string)
SetBaseURI sets the document base URI (used for resolving relative URIs and rdf:ID)
type ReifiedTriple ¶
type ReifiedTriple struct {
Identifier Term // The identifier (IRI or blank node) for this reified triple
Triple *QuotedTriple // The underlying quoted triple
}
ReifiedTriple represents a quoted triple with an explicit identifier (RDF 1.2 reification) Syntax: << s p o ~ identifier >> This is used internally during parsing to track that a quoted triple has an identifier
func (*ReifiedTriple) Equals ¶
func (r *ReifiedTriple) Equals(other Term) bool
func (*ReifiedTriple) String ¶
func (r *ReifiedTriple) String() string
func (*ReifiedTriple) Type ¶
func (r *ReifiedTriple) Type() TermType
type TermType ¶
type TermType byte
TermType represents the type of an RDF term
const ( // Core RDF types TermTypeNamedNode TermType = iota + 1 TermTypeBlankNode TermTypeLiteral TermTypeDefaultGraph TermTypeQuotedTriple // RDF 1.2: Triple terms // Literal subtypes TermTypeStringLiteral TermTypeLangStringLiteral TermTypeIntegerLiteral TermTypeDecimalLiteral TermTypeDoubleLiteral TermTypeBooleanLiteral TermTypeDateTimeLiteral TermTypeDateLiteral TermTypeTimeLiteral TermTypeDurationLiteral TermTypeTypedLiteral // Custom datatype (not XSD built-in) - MUST be last to preserve existing type values )
type TriGIOParser ¶
type TriGIOParser struct{}
TriGIOParser parses TriG format (Turtle + named graphs, quads)
func (*TriGIOParser) ContentType ¶
func (p *TriGIOParser) ContentType() string
type TriGParser ¶
type TriGParser struct {
// contains filtered or unexported fields
}
TriGParser parses TriG format (Turtle + named graphs)
func NewTriGParser ¶
func NewTriGParser(input string) *TriGParser
NewTriGParser creates a new TriG parser
func (*TriGParser) Parse ¶
func (p *TriGParser) Parse() ([]*Quad, error)
Parse parses the TriG document and returns quads
func (*TriGParser) SetBaseURI ¶
func (p *TriGParser) SetBaseURI(baseURI string)
SetBaseURI sets the base URI for resolving relative IRIs
type TripleTerm ¶
TripleTerm represents an RDF 1.2 triple term <<( s p o )>> (N-Triples 1.2 syntax in Turtle) Triple terms are NOT automatically reified when used as subjects/objects
func (*TripleTerm) Equals ¶
func (t *TripleTerm) Equals(other Term) bool
func (*TripleTerm) String ¶
func (t *TripleTerm) String() string
func (*TripleTerm) Type ¶
func (t *TripleTerm) Type() TermType
type TurtleIOParser ¶
type TurtleIOParser struct{}
TurtleIOParser parses Turtle format (triples with prefixes, default graph)
func (*TurtleIOParser) ContentType ¶
func (p *TurtleIOParser) ContentType() string
type TurtleParser ¶
type TurtleParser struct {
// contains filtered or unexported fields
}
TurtleParser is a simple Turtle/N-Triples parser for loading test data
func NewNTriplesParser ¶
func NewNTriplesParser(input string) *TurtleParser
NewNTriplesParser creates a new N-Triples parser with strict validation
func NewTurtleParser ¶
func NewTurtleParser(input string) *TurtleParser
NewTurtleParser creates a new Turtle parser
func (*TurtleParser) Parse ¶
func (p *TurtleParser) Parse() ([]*Triple, error)
Parse parses the Turtle document and returns triples
func (*TurtleParser) SetBaseURI ¶
func (p *TurtleParser) SetBaseURI(baseURI string)
SetBaseURI sets the base URI for resolving relative IRIs