meta

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Headers added in v0.1.1

func Headers(idx int, fields []Field) []string

Headers return headers for the output file. It takes idx parameter which corresponds to designated Index field of DwCA star schema. It also takes fields, which is a slice of fields that corresponds to the DwCA star schema.

Types

type Archive

type Archive struct {
	XMLName    xml.Name     `xml:"archive"`
	EMLFile    string       `xml:"metadata,attr"`
	Core       *Core        `xml:"core"`
	Extensions []*Extension `xml:"extension"`
}

type Attr

type Attr struct {
	Encoding           string  `xml:"encoding,attr"`
	FieldsTerminatedBy string  `xml:"fieldsTerminatedBy,attr"`
	LinesTerminatedBy  string  `xml:"linesTerminatedBy,attr"`
	FieldsEnclosedBy   string  `xml:"fieldsEnclosedBy,attr"`
	IgnoreHeaderLines  string  `xml:"ignoreHeaderLines,attr"`
	RowType            string  `xml:"rowType,attr"`
	Files              Files   `xml:"files"`
	Fields             []Field `xml:"field"`
}

Attr holds the common fields for Core and Extension.

type Core

type Core struct {
	ID ID `xml:"id"`
	*Attr
}

Core includes CommonElement and any core-specific fields (like ID).

type CoreData

type CoreData struct {
	// Index is the field index of the Core's Term.
	Index int

	// Term is the field name of the main Core Data (Topic).
	Term string

	// TermFull is the URI of the main Core Data (Topic).
	TermFull string

	// Location is the location of the Core file.
	Location string

	// FieldsData is a map of field Terms to their FieldData.
	FieldsData map[string]FieldData

	// FieldsIdx is a map of field indices to their FieldData.
	FieldsIdx map[int]FieldData
}

CoreData is a simplified version of Core data of the DwCA archive.

type CoreID

type CoreID struct {
	Index string `xml:"index,attr"`
	Idx   int    `xml:"-"`
}

CoreID holds the fields for the CoreID data.

type ErrMetaDecoder

type ErrMetaDecoder struct {
	//  OrigErr is the original error.
	OrigErr error
}

ErrMetaDecoder is an error type for decoding meta.xml files.

func (*ErrMetaDecoder) Error

func (e *ErrMetaDecoder) Error() string

type ErrMetaReader

type ErrMetaReader struct {
	// OrigErr is the original error.
	OrigErr error
}

ErrMetaReader is an error type for reading meta.xml files.

func (*ErrMetaReader) Error

func (e *ErrMetaReader) Error() string

type Extension

type Extension struct {
	CoreID CoreID `xml:"coreid"`
	*Attr
}

Extension includes CommonElement and any extension-specific fields (like CoreID).

type ExtensionData

type ExtensionData struct {
	// CoreIndex is the index of the Core main field in the Extension.
	// It allows to create a star schema of the DwCA archive.
	CoreIndex int

	// Location is the location of the Extension file.
	Location string

	// FieldsData is a map of field Terms to their FieldData.
	FieldsData map[string]FieldData

	// FieldsIdx is a map of field indices to their FieldData.
	FieldsIdx map[int]FieldData
}

ExtensionData is a simplified version of Extensions data of the DwCA.

type Field

type Field struct {
	// Index is the verbatim index of the field.
	Index string `xml:"index,attr"`

	// Idx is the int version of Index.
	Idx int `xml:"-"`

	// Term is the URI of the term.
	Term string `xml:"term,attr"`
}

Field holds the fields of the data.

type FieldData

type FieldData struct {
	// Index is the index of the field in the DwCA archive.
	Index int

	// Term is the field name of the field.
	Term string

	// TermFull is the URI of the field.
	TermFull string
}

FieldData is a simplified version of a field in the DwCA archive.

type Files

type Files struct {
	// Location provides path to a file.
	Location string `xml:"location"`
}

Files holds the location of files.

type ID

type ID struct {
	Index string `xml:"index,attr"`
	Idx   int    `xml:"-"`
	Term  string `xml:"term,attr"`
}

ID holds the fields for the Core ID.

type Meta

type Meta struct {
	Archive `xml:"archive"`
}

func New

func New(r io.Reader) (*Meta, error)

New reads an Meta file from an io.Reader and returns an EML struct.

func (*Meta) Bytes

func (m *Meta) Bytes() ([]byte, error)

func (*Meta) Simplify

func (m *Meta) Simplify() *MetaSimple

type MetaSimple

type MetaSimple struct {
	// CoreData is a simplified version of Core data of the DwCA archive.
	CoreData

	// ExtensionsData is a simplified version of Extensions data of the DwCA.
	ExtensionsData map[string]ExtensionData
}

MetaSimple is a simplifiec version of Meta object, that is used to access metadata fields by their names or indices.

Jump to

Keyboard shortcuts

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