Documentation ¶
Overview ¶
Package marc implements decoding of MARCXML (MarcXchange (ISO25577) bibliographic MARC records, and convenience methods for extracting values from record fields.
Index ¶
- func Unmarshal(b []byte, rec *Record) error
- type ControlField
- type DataField
- type Decoder
- type Record
- func (r Record) ControlFieldAt(tag string) (ControlField, bool)
- func (r Record) DataFieldAt(tag string) (DataField, bool)
- func (r Record) DataFieldsAt(tags ...string) (res []DataField)
- func (r Record) IsEmpty() bool
- func (r Record) ValueAt(tag, code string) string
- func (r Record) ValuesAt(tag, code string) (res []string)
- type Relator
- type SubField
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ControlField ¶
type ControlField struct { Tag string `xml:"tag,attr"` // 3 chars Value string `xml:",chardata"` // if Tag == "000"; 40 chars }
ControlField represents a control field in a MARC record.
type DataField ¶
type DataField struct { Tag string `xml:"tag,attr"` // 3 chars Ind1 string `xml:"ind1,attr"` // 1 char Ind2 string `xml:"ind2,attr"` // 1 char SubFields []SubField `xml:"subfield"` }
DataField represents a data field in a MARC record.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder can decode MARC records from a stream.
func NewDecoder ¶
NewDecoder returns a new Decoder for the given reader.
type Record ¶
type Record struct { XMLName xml.Name `xml:"record"` Leader string `xml:"leader"` // 24 chars ControlFields []ControlField `xml:"controlfield"` DataFields []DataField `xml:"datafield"` }
Record represents a MARC record.
func MustParse ¶
MustParse parses the give MARCXML-encoded data and records a Record, but panics on errors.
func MustParseString ¶
MustParseString is like MustParse, except it accepts a string instead.
func (Record) ControlFieldAt ¶
func (r Record) ControlFieldAt(tag string) (ControlField, bool)
ControlFieldAt returns the control field of the given tag, along with a boolean denoting if it was found or not.
func (Record) DataFieldAt ¶
DataFieldAt returns the first occurrence of DataField with the given tag, along with a boolean denoting if it was found or not.
func (Record) DataFieldsAt ¶
DataFieldsAt returns all occurrences of DataFields with the given tags.
type Relator ¶
type Relator struct {
// contains filtered or unexported fields
}
Relator is a known Marc relator, associated with a 3-letter code. The codes are maintained by Library of Congress. TODO drop struct; type Relator string suffices
func ParseRelator ¶
ParseRelator parses the given string and returns a Relator if it matches a known 3-letter Marc Relator code.