marc21

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package marc21 reads MARC21 and MARCXML data.

Enables converting between MARC21 and MARCXML data.

Index

Constants

View Source
const (
	// FmtUnknown indicates that the record format is not known or not specified
	FmtUnknown = iota
	// Bibliography indicates that the record is a Bibliography (or bib-holding) record
	Bibliography
	// Holdings indicates that the record is a Holdings record
	Holdings
	// Authority indicates that the record is an Authority record
	Authority
	// Classification indicates that the record is a Classification record
	Classification
	// Community indicates that the record is a Community Information record
	Community
)
View Source
const CollectionXMLFooter = `</marc:collection>
`

CollectionXMLFooter being the footer (closing collection tag) of a MARCXML document

View Source
const CollectionXMLHeader = `` /* 274-byte string literal not displayed */

CollectionXMLHeader being the header (XML declaration and opening collection tag) of a MARCXML document

Variables

This section is empty.

Functions

func NextRecord

func NextRecord(r io.Reader) (rawRec []byte, err error)

NextRecord reads the next MARC record and returns the unparsed bytes

Types

type Collection

type Collection struct {
	Name    xml.Name  `xml:"collection"`
	Records []*Record `xml:"record"`
}

Collection is for containing zero or more MARC records

func LoadXML

func LoadXML(filename string) (Collection, error)

LoadXML reads a MARCXML document

func (Collection) AsXML

func (c Collection) AsXML() (ret string, err error)

AsXML converts an entire collection to XML

type Controlfield

type Controlfield struct {
	Tag  string `xml:"tag,attr"`
	Text string `xml:",chardata"`
}

Controlfield contains a controlfield entry

func (Controlfield) GetTag

func (cf Controlfield) GetTag() string

GetTag returns the tag for the controlfield

func (Controlfield) GetText

func (cf Controlfield) GetText() string

GetText returns the text for the controlfield

func (Controlfield) String

func (cf Controlfield) String() string

Implement the Stringer interface for "Pretty-printing"

type Datafield

type Datafield struct {
	Tag       string      `xml:"tag,attr"`
	Ind1      string      `xml:"ind1,attr"`
	Ind2      string      `xml:"ind2,attr"`
	Subfields []*Subfield `xml:"subfield"`
}

Datafield contains a datafield entry

func (Datafield) GetInd1

func (df Datafield) GetInd1() string

GetInd1 returns the indicator 1 value for the datafield

func (Datafield) GetInd2

func (df Datafield) GetInd2() string

GetInd2 returns the indicator 2 value for the datafield

func (Datafield) GetSubfields

func (df Datafield) GetSubfields(codes string) (sfs []*Subfield)

GetSubfields returns subfields for the datafield that match the specified codes. If no codes are specified (empty string) then all subfields are returned

func (Datafield) GetTag

func (df Datafield) GetTag() string

GetTag returns the tag for the datafield

type Leader

type Leader struct {
	Text string `xml:",chardata"`
}

Leader is for containing the text string of the MARC record Leader

func (Leader) GetText

func (ldr Leader) GetText() string

GetText returns the text for the leader

type Record

type Record struct {
	Leader        Leader          `xml:"leader"`
	Controlfields []*Controlfield `xml:"controlfield"`
	Datafields    []*Datafield    `xml:"datafield"`
}

Record is for containing a MARC record

func ParseNextRecord

func ParseNextRecord(r io.Reader) (rec *Record, err error)

ParseNextRecord reads the next MARC record and returns the parsed record structure

func ParseRecord

func ParseRecord(rawRec []byte) (rec *Record, err error)

ParseRecord takes the bytes for a MARC record and returns the parsed record structure

func (Record) AsXML

func (rec Record) AsXML() (ret string, err error)

AsXML converts record to XML

func (Record) BibliographyMaterialType

func (rec Record) BibliographyMaterialType() (code, label string)

BibliographyMaterialType returns the code and description of the type of material documented by Bibliography the record. {"Books", "Computer Files", "Maps", "Music", "Continuing Resources", "Visual Materials" or "Mixed Materials"}

func (Record) CharacterCodingScheme

func (rec Record) CharacterCodingScheme() (code, label string)

CharacterCodingScheme returns the code and label indicating the "09 - Character coding scheme" of the record (MARC-8 or UCS/Unicode).

func (Record) GetControlfield

func (rec Record) GetControlfield(tag string) string

GetControlfield returns the text value of the first control field for the record that matches the specified (presumably non-repeating) tag

func (Record) GetControlfields

func (rec Record) GetControlfields(tags string) (cfs []*Controlfield)

GetControlfields returns the unique set of controlfields for the record that match the specified tags. If no tags are specified (empty string) then all controlfields are returned

func (Record) GetDatafields

func (rec Record) GetDatafields(tags string) (dfs []*Datafield)

GetDatafields returns datafields for the record that match the specified comma separated list of tags. If no tags are specified (empty string) then all datafields are returned

func (Record) RecordAsMARC

func (rec Record) RecordAsMARC() (marc []byte, err error)

RecordAsMARC converts a Record into a MARC record byte array

func (Record) RecordFormat

func (rec Record) RecordFormat() int

RecordFormat indicates the high level nature of the record and is used to differentiate between Bibliography, Holdings, Authority, Classification, and Community record formats.

func (Record) RecordFormatName

func (rec Record) RecordFormatName() string

RecordFormatName indicates the name of the format of the record and is used to differentiate between Bibliography, Holdings, Authority, Classification, and Community record formats.

func (Record) RecordType

func (rec Record) RecordType() (code, label string)

RecordType returns the one character code and label indicating the "06 - Type of record" for the record. Use RecordFormat to determine the record format (bibliographic, holdings, etc.)

func (Record) String

func (rec Record) String() string

Implement the Stringer interface for "Pretty-printing"

type Subfield

type Subfield struct {
	Code string `xml:"code,attr"`
	Text string `xml:",chardata"`
}

Subfield contains a subfield entry

func (Subfield) GetCode

func (sf Subfield) GetCode() string

GetCode returns the code for the subfield

func (Subfield) GetText

func (sf Subfield) GetText() string

GetText returns the text for the subfield

Jump to

Keyboard shortcuts

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