dublincore

package
v0.33.0 Latest Latest
Warning

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

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

Documentation

Overview

Package dublincore converts MARC 21 records to Dublin Core (DCMI), the lowest-common-denominator metadata used by OAI-PMH and most repository software. It emits the OAI oai_dc XML form and a DC-in-JSON form.

Dublin Core is a different, flat and lossy model (15 repeatable elements), so this is a one-way MARC->DC crosswalk, not a codec. The Writers implement codex.RecordWriter, so they plug into codex.Convert as conversion targets:

w := dublincore.NewWriter(out) // oai_dc XML; or NewJSONWriter for DC-JSON
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 oai_dc XML document.

func EncodeJSON

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

EncodeJSON converts a record to a compact Dublin Core JSON object.

func WriteFile

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

WriteFile writes every record to the named file as an oai_dc XML collection.

Types

type DC

type DC struct {
	Title       []string
	Creator     []string
	Subject     []string
	Description []string
	Publisher   []string
	Contributor []string
	Date        []string
	Type        []string
	Format      []string
	Identifier  []string
	Source      []string
	Language    []string
	Relation    []string
	Coverage    []string
	Rights      []string
}

DC holds the fifteen Dublin Core elements, each repeatable.

func FromRecord

func FromRecord(r *codex.Record) *DC

FromRecord maps a MARC record to Dublin Core in a single pass over the fields.

type JSONWriter

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

JSONWriter converts records and writes them as a JSON array of DC objects.

func NewJSONWriter

func NewJSONWriter(w io.Writer) *JSONWriter

NewJSONWriter returns a Writer that writes a JSON array of Dublin Core objects.

func (*JSONWriter) Close

func (wr *JSONWriter) Close() error

func (*JSONWriter) Write

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

type Writer

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

Writer converts records and writes them as oai_dc elements within a <dcCollection>. Close must be called to emit the closing tag.

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter returns a Writer that writes an oai_dc XML collection to w.

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