Skip to content

Commit afa584c

Browse files
committed
Update sessopm 5 and 11
1 parent 0964b7b commit afa584c

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

05-More-Fix-Concepts.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,6 @@ colours:
197197
and you use the fix
198198

199199
```PERL
200-
add_array("result") # To create a new array named result
201-
202200
upcase("colours[].*")
203201
append("colours[].*"," is a nice color")
204202
copy_field("colours[].*","result.$append")
@@ -221,28 +219,26 @@ If you want to only change it, under a certain condition:
221219

222220
```PERL
223221
if any_equal("colours[]","green")
224-
add_array("result[]") # To create a new array named result
225222
upcase("colours[].*")
226223
append("colours[].*"," is a nice color")
227224
copy_field("colours[].*","result[].$append")
228225
end
229226
```
230227

231-
[This still transforms the all elements of an array because the conditional tests all elements not each individually.](https://metafacture.org/playground/?flux=inputFile%0A%7C+open-file%0A%7C+as-records%0A%7C+decode-yaml%0A%7C+fix%28transformationFile%29%0A%7C+encode-yaml%0A%7C+print%0A%3B&transformation=if+any_equal%28%22colours%5B%5D%22%2C%22green%22%29%0A++add_array%28%22result%22%29+%23+To+create+a+new+array+named+result%0A%0A++upcase%28%22colours%5B%5D.%2A%22%29%0A++append%28%22colours%5B%5D.%2A%22%2C%22+is+a+nice+color%22%29%0A++copy_field%28%22colours%5B%5D.%2A%22%2C%22result.%24append%22%29%0Aend&data=---%0Acolours%3A%0A+-+red%0A+-+yellow%0A+-+green)
228+
[This still transforms the all elements of an array because the conditional tests all elements not each individually.](https://metafacture.org/playground/?flux=inputFile%0A%7C+open-file%0A%7C+as-records%0A%7C+decode-yaml%0A%7C+fix%28transformationFile%29%0A%7C+encode-yaml%0A%7C+print%0A%3B&transformation=if+any_equal%28%22colours%5B%5D%22%2C%22green%22%29%0A++upcase%28%22colours%5B%5D.%2A%22%29%0A++append%28%22colours%5B%5D.%2A%22%2C%22+is+a+nice+color%22%29%0A++copy_field%28%22colours%5B%5D.%2A%22%2C%22result.%24append%22%29%0Aend&data=---%0Acolours%3A%0A+-+red%0A+-+yellow%0A+-+green)
232229
To only tranform and copy the value `green` to an X you have to use the `do list`-Bind:
233230

234231
```PERL
235232
do list(path:"colours[]","var":"$i")
236233
if any_equal("$i","green")
237-
add_array("result[]") # To create a new array named result
238234
upcase("$i")
239235
append("$i"," is a nice color")
240236
copy_field("$i","result[].$append")
241237
end
242238
end
243239
```
244240

245-
[See this example here in the playground.](https://metafacture.org/playground/?flux=inputFile%0A%7C+open-file%0A%7C+as-records%0A%7C+decode-yaml%0A%7C+fix%28transformationFile%29%0A%7C+encode-yaml%0A%7C+print%0A%3B&transformation=do+list%28path%3A%22colours%5B%5D%22%2C%22var%22%3A%22%24i%22%29%0A++++if+any_equal%28%22%24i%22%2C%22green%22%29%0A++++++++add_array%28%22result%5B%5D%22%29+%23+To+create+a+new+array+named+result%0A++++++++upcase%28%22%24i%22%29%0A++++++++append%28%22%24i%22%2C%22+is+a+nice+color%22%29%0A++++++++copy_field%28%22%24i%22%2C%22result%5B%5D.%24append%22%29%0A++++end%0Aend&data=---%0Acolours%3A%0A+-+red%0A+-+yellow%0A+-+green)
241+
[See this example here in the playground.](https://metafacture.org/playground/?flux=inputFile%0A%7C+open-file%0A%7C+as-records%0A%7C+decode-yaml%0A%7C+fix%28transformationFile%29%0A%7C+encode-yaml%0A%7C+print%0A%3B&transformation=do+list%28path%3A%22colours%5B%5D%22%2C%22var%22%3A%22%24i%22%29%0A++++if+any_equal%28%22%24i%22%2C%22green%22%29%0A++++++++upcase%28%22%24i%22%29%0A++++++++append%28%22%24i%22%2C%22+is+a+nice+color%22%29%0A++++++++copy_field%28%22%24i%22%2C%22result%5B%5D.%24append%22%29%0A++++end%0Aend&data=---%0Acolours%3A%0A+-+red%0A+-+yellow%0A+-+green)
246242

247243
For the supported binds see: https://metafacture.github.io/metafacture-documentation/docs/fix/Fix-functions.html#selectors
248244

11_MARC_to_Dublin_Core.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,19 @@ And type into this textfile the following fixes:
99

1010
```PERL
1111
copy_field("245??.a","title")
12-
add_array("creator[]")
1312
copy_field("100??.a","creator[].$append")
1413
copy_field("700??.a","creator[].$append")
1514
copy_field("260??.c","date")
1615
copy_field("260??.b","publisher")
1716

18-
add_array("isbn[]")
1917
do list(path:"020??","var":"$i")
2018
copy_field("$i.a","isbn[].$append")
2119
end
22-
add_array("issn[]")
20+
2321
do list(path:"022??","var":"$i")
2422
copy_field("$i.a","issn[].$append")
2523
end
2624

27-
add_array("subject[]")
2825
do list(path:"650??","var":"$i")
2926
copy_field("$i.a","subject[].$append")
3027
end
@@ -87,10 +84,8 @@ Congratulations, you’ve created your first mapping file to transform library d
8784
Below you’ll find a complete example. You can read more about our Fix language online.
8885

8986
```PERL
90-
add_array("title")
9187
copy_field("245??.?","title.$append")
9288
join_field("title", " ")
93-
add_array("creator[]")
9489
copy_field("100??.a","creator[].$append")
9590
copy_field("700??.a","creator[].$append")
9691
copy_field("260??.c","date")
@@ -100,19 +95,16 @@ replace_all("publisher",",$","")
10095
10196
add_field("type","BibliographicResource")
10297
103-
add_array("isbn[]")
10498
do list(path:"020??","var":"$i")
10599
copy_field("$i.a","isbn[].$append")
106100
end
107101
replace_all("isbn.*"," .","")
108102
109-
add_array("issn[]")
110103
do list(path:"022??","var":"$i")
111104
copy_field("$i.a","issn[].$append")
112105
end
113106
replace_all("issn.*"," .","")
114107
115-
add_array("subject[]")
116108
do list(path:"650??","var":"$i")
117109
copy_field("$i.a","subject[].$append")
118110
end

0 commit comments

Comments
 (0)