Documentation
¶
Overview ¶
Package bibframe converts MARC 21 records to BIBFRAME 2.0, the Library of Congress linked-data model that replaces the flat MARC record with an RDF graph of related resources: a bf:Work (the intellectual content) and a bf:Instance (a particular publication of it), linked by bf:instanceOf / bf:hasInstance.
BIBFRAME is a different data model than MARC — a graph, not a leader+fields record — so this is a one-way MARC->BIBFRAME crosswalk, not a codec, following a subset of the LoC marc2bibframe2 mapping. Two serializations are produced, both hand-written with the standard library only (no RDF dependency):
- RDF/XML (Encode / Writer / WriteFile) — the canonical LoC serialization.
- JSON-LD (EncodeJSONLD / JSONLDWriter / WriteJSONLDFile).
The collection Writers implement codex.RecordWriter, so they plug into codex.Convert as conversion targets; both wrap their records in a container (an rdf:RDF element or a JSON-LD @graph) and must be closed:
w := bibframe.NewWriter(out) // RDF/XML; or NewJSONLDWriter for JSON-LD codex.Convert(iso2709.NewReader(src), w) w.Close()
The crosswalk covers the common fields (titles, contributions, subjects, language, classification, summary on the Work; title, provision, extent, edition, identifiers and electronic locator on the Instance). Fields outside that set are not carried, and BIBFRAME cannot round-trip back to full MARC.
Index ¶
- func Encode(r *codex.Record) ([]byte, error)
- func EncodeJSONLD(r *codex.Record) ([]byte, error)
- func WriteFile(path string, records []*codex.Record) error
- func WriteJSONLDFile(path string, records []*codex.Record) error
- type BIBFRAME
- type Classification
- type Contribution
- type Identifier
- type Instance
- type JSONLDWriter
- type Provision
- type Subject
- type Title
- type Work
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeJSONLD ¶
EncodeJSONLD converts a record to a standalone BIBFRAME JSON-LD document.
func WriteJSONLDFile ¶
WriteJSONLDFile converts every record to a BIBFRAME JSON-LD file.
Types ¶
type BIBFRAME ¶
BIBFRAME is the Work/Instance pair derived from one MARC record.
func FromRecord ¶
func FromRecord(r *codex.Record) *BIBFRAME
FromRecord maps a MARC record to a BIBFRAME Work/Instance pair in a single pass over the fields, following the common-field crosswalk.
type Classification ¶
type Classification struct {
Class string // "ClassificationLcc" or "ClassificationDdc"
Value string
}
Classification is a call number with its BIBFRAME class.
type Contribution ¶
type Contribution struct {
Primary bool // a bflc:PrimaryContribution (1xx) vs a plain bf:Contribution (7xx)
Class string // agent class: "Person", "Organization" or "Meeting"
Label string // agent name
Role string // role term, or ""
}
Contribution links an Agent to the Work with an optional role.
type Identifier ¶
Identifier is a typed identifier carried by the Instance.
type Instance ¶
type Instance struct {
Titles []Title
ResponsibilityStatement string
EditionStatement string
Provision *Provision
Extent []string
Identifiers []Identifier
ElectronicLocator []string
}
Instance is a particular publication of the Work (bf:Instance).
type JSONLDWriter ¶
type JSONLDWriter struct {
// contains filtered or unexported fields
}
JSONLDWriter converts records and writes them into a JSON-LD @graph array. Close must be called to terminate the document.
func NewJSONLDWriter ¶
func NewJSONLDWriter(w io.Writer) *JSONLDWriter
NewJSONLDWriter returns a Writer that writes a BIBFRAME JSON-LD document to w.
func (*JSONLDWriter) Close ¶
func (wr *JSONLDWriter) Close() error
func (*JSONLDWriter) Write ¶
func (wr *JSONLDWriter) Write(r *codex.Record) error
type Subject ¶
type Subject struct {
Class string // "Topic", "Place", "Person", "Organization" or "Meeting"
Label string
}
Subject is a topical, geographic or name access point on the Work.
type Title ¶
type Title struct {
Type string // "" for the transcribed title, "uniform" for 130/240
MainTitle string
Subtitle string
PartNumber string
PartName string
}
Title is a bf:Title with its component portions.
type Work ¶
type Work struct {
Class string // bf class refining bf:Work (e.g. "Text"), or ""
Titles []Title
Contributions []Contribution
Subjects []Subject
GenreForms []string
Languages []string // ISO 639-2 codes
Classifications []Classification
Summary []string
}
Work is the intellectual content (bf:Work) plus a specific content class.