schemaorg

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package schemaorg converts MARC 21 records to schema.org JSON-LD — the vocabulary search engines and reading systems consume on the web. Each record becomes a Book (or a related CreativeWork subtype) carrying the common bibliographic fields plus schema.org accessibility metadata (accessMode, accessibilityFeature, accessibilitySummary) derived from the record's 008, 007, 341 and 532 fields.

schema.org is a different, flat model, so this is a one-way MARC->schema.org crosswalk, not a codec. The Writer emits a JSON array and implements codex.RecordWriter, so it plugs into codex.Convert; it must be closed:

w := schemaorg.NewWriter(out)
codex.Convert(iso2709.NewReader(src), w)
w.Close()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(r *codex.Record) ([]byte, error)

Encode converts a record to a standalone schema.org JSON-LD object.

func WriteFile

func WriteFile(path string, records []*codex.Record) error

WriteFile writes every record to the named file as a schema.org JSON-LD array.

Types

type Agent

type Agent struct {
	Type string // "Person" or "Organization"
	Name string
}

Agent is a schema.org Person or Organization.

type Book

type Book struct {
	Type          string
	Name          string
	Authors       []Agent
	Contributors  []Agent
	Publisher     string
	DatePublished string
	ISBN          []string
	ISSN          []string
	InLanguage    []string
	About         []string
	Genre         []string
	Edition       string
	URL           []string
	Description   string

	// Accessibility (schema.org a11y vocabulary).
	AccessMode           []string
	AccessibilityFeature []string
	AccessibilitySummary string
}

Book is the schema.org representation of a record. Empty fields are omitted.

func FromRecord

func FromRecord(r *codex.Record) *Book

FromRecord maps a MARC record to a schema.org Book in a single pass.

type Writer

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

Writer converts records and writes them as a JSON array of schema.org objects. Close must be called to terminate the array.

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter returns a Writer that writes a JSON array of schema.org Book objects.

func (*Writer) Close

func (wr *Writer) Close() error

func (*Writer) Write

func (wr *Writer) Write(r *codex.Record) error

Jump to

Keyboard shortcuts

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