Mapping rules

Carsten Klee edited this page Mar 31, 2017 · 28 revisions

Given the MARC record:

245  $aTitle / $cName
500  $aA$aB$aC$xD
650  $aAlpha
650  $aBeta
650  $aGamma
999  $aX$aY
999  $aZ

Single field, no subfield repetition

245 has only unique subfield codes

245  $aTitle / $cName
Fix Result
marc_map(245, title)
marc_spec(245, title)
title: "Title / Name"
marc_map(245a, title)
marc_map(245$a, title)
marc_spec(245$a, title)
title: "Title / "
marc_map(245ac, title)
marc_map(245$a$c, title)
marc_spec(245$a$c, title)
title: "Title / Name"
marc_map(245ca, title)
marc_map(245$c$a, title)
marc_spec(245$c$a, title)
title: "Title / Name"
marc_map(245ca, title, pluck:1)
marc_map(245$c$a, title, pluck:1)
marc_spec(245$c$a, title, pluck:1)
title: "NameTitle / "
marc_map(245ca, title, pluck:1, join:" ")
marc_map(245$c$a, title, pluck:1, join:" ")
marc_spec(245$c$a, title, pluck:1, join:" ")
title: "Name Title / "
marc_spec(245$a, title, invert:1) title: "Name"

Append adds the result to a list

Fix Result
marc_map(245, title.$append)
marc_spec(245, title.$append)
title: ["Title / Name"]
marc_map(245a, title.$append)
marc_map(245$a, title.$append)
marc_spec(245$a, title.$append)
title: ["Title / "]

Split creates a list out of subfields

Fix Result
marc_map(245, title, split:1)
marc_spec(245, title, split:1)
title: ["Title / ", "Name"]
marc_map(245, title.$append, split:1)
marc_spec(245, title.$append, split:1)
title: [["Title / ", "Name"]]

Nest creates a list for every field found

Fix Result
marc_map(245, title, split:1, nested_arrays:1)
marc_spec(245, title, split:1, nested_arrays:1)
title: [["Title / ", "Name"]]
marc_map(245, title.$append, split:1, nested_arrays:1)
marc_spec(245, title.$append, split:1, nested_arrays:1)
title: [[["Title / ", "Name"]]]

Single field, repeated subfields

Field 500 has repeated subfields

500  $aA$aB$aC$xD
Fix Result
marc_map(500, note)
marc_spec(500, note)
note: "ABCD"
marc_map(500a, note)
marc_map(500$a, note)
marc_spec(500$a, note)
note: "ABC"
marc_spec(500$a, note, invert:1) note: "D"

Append adds the result to a list

Fix Result
marc_map(500, note.$append)
marc_spec(500, note.$append)
note: ["ABCD"]
marc_map(500a, note.$append)
marc_spec(500$a, note.$append)
note: ["ABC"]
marc_spec(500$a, note.$append, invert:1) note: ["D"]

Split creates a list out of subfields

Fix Result
marc_map(500, note, split:1)
note: ["A", "B", "C", "D"]
marc_map(500a, note, split:1)
marc_map(500$a, note, split:1)
marc_spec(500$a, note, split:1)
note: ["A", "B", "C"]
marc_map(500a, note.$append, split:1)
marc_map(500$a, note.$append, split:1)
marc_spec(500$a, note.$append, split:1)
note : [["A", "B", "C"]]

Nest creates a list for every field found

Fix Result
marc_map(500a, note, split:1, nested_arrays:1)
marc_map(500$a, note, split:1, nested_arrays:1)
marc_spec(500$a, note, split:1, nested_arrays:1)
note: [["A", "B", "C"]]
marc_map(500a, note.$append, split:1, nested_arrays: 1)
marc_map(500$a, note.$append, split:1, nested_arrays: 1)
marc_spec(500$a, note.$append, split:1, nested_arrays: 1)
note : [[["A", "B", "C"]]]

Repeated Field, no subfield repetition

Field 650 is repeated

650  $aAlpha
650  $aBeta
650  $aGamma
Fix Result
marc_map(650, subject)
marc_spec(650, subject)
subject: "AlphaBetaGamma"
marc_map(650a, subject)
marc_map(650$a, subject)
marc_spec(650$a, subject)
subject: "AlphaBetaGamma"

Append adds the result to a list

Fix Result
marc_map(650a, subject.$append)
marc_map(650$a, subject.$append)
marc_spec(650$a, subject.$append)
subject: ["Alpha", "Beta", "Gamma"]

Split creates a list out of subfields

Fix Result
marc_map(650a, subject, split:1)
marc_map(650$a, subject, split:1)
marc_spec(650$a, subject, split:1)
subject: ["Alpha", "Beta", "Gamma"]
marc_map(650a, subject.$append, split:1)
marc_map(650$a, subject.$append, split:1)
marc_spec(650$a, subject.$append, split:1)
subject: [["Alpha", "Beta", "Gamma"]]

Nest creates a list for every field found

Fix Result
marc_map(650a, subject, split:1, nested_arrays:1)
marc_map(650$a, subject, split:1, nested_arrays:1)
marc_spec(650$a, subject, split:1, nested_arrays:1)
subject: [["Alpha"], ["Beta"], ["Gamma"]]
marc_map(650a, subject.$append, split:1, nested_arrays:1)
marc_map(650$a, subject.$append, split:1, nested_arrays:1)
marc_spec(650$a, subject.$append, split:1, nested_arrays:1)
subject: [[["Alpha"], ["Beta"], ["Gamma"]]]

Repeated field with repeated subfields

Field 999 has repeated fields and subfields

999  $aX$aY
999  $aZ
Fix Result
marc_map(999, local)
marc_spec(999, local)
local: "XYZ"
marc_map(999a, local)
marc_map(999$a, local)
marc_spec(999$a, local)
local: "XYZ"

Append adds the result to a list

Fix Result
marc_map(999a, local.$append)
marc_map(999$a, local.$append)
marc_spec(999$a, local.$append)
local: ["XY", "Z"]

Split creates a list out of subfields

Fix Result
marc_map(999a, local, split:1)
marc_map(999$a, local, split:1)
marc_spec(999$a, local, split:1)
local: ["X", "Y", "Z"]
marc_map(999a, local.$append, split:1)
marc_map(999$a, local.$append, split:1)
marc_spec(999$a, local.$append, split:1)
local: [["X", "Y", "Z"]]

Nest creates a list for every field found

Fix Result
marc_map(999a, local, split:1, nested_arrays:1)
marc_map(999$a, local, split:1, nested_arrays:1)
marc_spec(999$a, local, split:1, nested_arrays:1)
local: [["X", "Y"], ["Z"]]
marc_map(999a, local.$append, split:1, nested_arrays:1)
marc_map(999$a, local.$append, split:1, nested_arrays:1)
marc_spec(999$a, local.$append, split:1, nested_arrays:1)
local: [[["X", "Y"], ["Z"]]]

Referencing the whole record

The dot (.) is a wildcard

(...) means take any field

245  $aTitle / $cName
500  $aA$aB$aC$xD
650  $aAlpha
650  $aBeta
650  $aGamma
999  $aX$aY
999  $aZ
Fix Result
marc_map(..., all)
marc_spec(..., all)
all: "Title / NameABCDAlphaBetaGammaXYZ"
marc_map(...a, all)
marc_map(...$a, all)
marc_spec(...$a, all)
all: "Title / ABCAlphaBetaGammaXYZ"
marc_spec(...$a, invert:1) all: "Name"

Append adds the result to a list

Fix Result
marc_map(...a, all.$append)
marc_map(...$a, all.$append)
marc_spec(...$a, all.$append)
all: ["Title / ", "ABC", "Alpha", "Beta", "Gamma", "XY", "Z"]

Split creates a list out of subfields

Fix Result
marc_map(...a, all, split:1)
marc_map(...$a, all, split:1)
marc_spec(...$a, all, split:1)
all: ["Title / ", "A", "B", "C", "Alpha", "Beta", "Gamma", "X", "Y", "Z"]
marc_map(...a, all.$append, split:1)
marc_map(...$a, all.$append, split:1)
marc_spec(...$a, all.$append, split:1)
all: [["Title / ", "A", "B", "C", "Alpha", "Beta", "Gamma", "X", "Y", "Z"]]

Nest creates a list for every field found

Fix Result
marc_map(...a, all, split:1, nested_arrays:1)
marc_map(...$a, all, split:1, nested_arrays:1)
marc_spec(...$a, all, split:1, nested_arrays:1)
all: [["Title / "], ["A", "B", "C"], ["Alpha"], ["Beta"], ["Gamma"], ["X", "Y"], ["Z"]]
marc_map(...a, all.$append, split:1, nested_arrays:1)
marc_map(...$a, all.$append, split:1, nested_arrays:1)
marc_spec(...$a, all.$append, split:1, nested_arrays:1)
all: [[["Title / "], ["A", "B", "C"], ["Alpha"], ["Beta"], ["Gamma"], ["X", "Y"], ["Z"]]]
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.