Skip to content

Commit e2bd22d

Browse files
committed
Add integration test replace_all (#251)
1 parent 101a371 commit e2bd22d

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<collection xmlns="http://www.loc.gov/MARC21/slim">
3+
<record>
4+
<datafield tag="700" ind1="1" ind2=" ">
5+
<subfield code="a">COLEMAN, Julie</subfield>
6+
<subfield code="e">Editor</subfield>
7+
<subfield code="a">KAY, Christian J.</subfield>
8+
<subfield code="e">NS</subfield>
9+
</datafield>
10+
</record>
11+
</collection>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
set_array("contribution[]")
2+
3+
do list(path:"700[01] ", "var":"$i")
4+
unless exists("$i.M")
5+
unless exists("$i.4")
6+
add_field("$i.4","ctb")
7+
end
8+
do list(path: "$i.4", "var":"$j")
9+
set_hash("contribution[].$append.agent")
10+
do list(path:"$i.0","var":"$k")
11+
if all_match("$k", "^\\(DE-588\\).*$")
12+
paste("contribution[].$last.agent.gndIdentifier","$k")
13+
paste("contribution[].$last.agent.id","$k")
14+
end
15+
end
16+
copy_field("$i.a","contribution[].$last.agent.label")
17+
set_array("contribution[].$last.agent.type[]","Person")
18+
copy_field("$j","contribution[].$last.role.id")
19+
end
20+
end
21+
end
22+
23+
set_array("contribution[].*.type[]", "Contribution")
24+
replace_all("contribution[].*.agent.id","^\\(DE-588\\)(.*$)","https://d-nb.info/gnd/$1")
25+
replace_all("contribution[].*.agent.label","(?<!\\p{Upper})\\.$|[,]$","")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FLUX_DIR + "input.xml"
2+
|open-file
3+
|decode-xml
4+
|handle-marcxml
5+
|fix(FLUX_DIR + "test.fix")
6+
|encode-json(prettyPrinting="true")
7+
|write(FLUX_DIR + "output-metafix.json")
8+
;

0 commit comments

Comments
 (0)