diff --git a/src/zbmath_rest2oai/getAsXml.py b/src/zbmath_rest2oai/getAsXml.py
index 21148790..3b1a0c5f 100644
--- a/src/zbmath_rest2oai/getAsXml.py
+++ b/src/zbmath_rest2oai/getAsXml.py
@@ -1,3 +1,4 @@
+import os
import re
import sys
@@ -77,43 +78,67 @@ def extract_tags(result):
def add_references_to_software(api_uri, dict_res):
list_articles_ids_to_soft = []
list_articles_ids_and_alter_ids_to_soft = []
+ list_articles_ids_and_years = []
+
if "software" in api_uri:
- if api_uri.startswith("https://api.zbmath.org/v1/software/_all?start_after=")==False:
- soft_id=api_uri.split("/")[-1]
+ if not (api_uri.
+ startswith("https://api.zbmath.org/v1/software/_all?start_after=")):
+ soft_id = api_uri.split("/")[-1]
+
def api_doc_endpoint(page):
- return requests.get("https://api.zbmath.org/v1/document/_structured_search?page={}&results_per_page=100&software%20id={}".format(page,soft_id))
- page=0
+ return requests.get(
+ "https://api.zbmath.org/v1/document/_structured_search?page={}&results_per_page=100&software%20id={}".format(
+ page, soft_id
+ )
+ )
+
+ page = 0
while True:
data = api_doc_endpoint(page).json()
if data is None or "result" not in data or not data["result"]:
break
- list_ids=[]
- list_ids_and_alter = []
for entry in data["result"]:
- list_ids.append(entry["id"])
+ list_ids = []
list_links = []
+ year = "Unknown"
+
+ if "year" in entry:
+ year = entry["year"]
+
+ list_ids.append(entry["id"])
for alt_dic in entry["links"]:
if alt_dic["type"] == "doi":
list_links.append(alt_dic["identifier"])
elif alt_dic["type"] == "arxiv":
list_links.append(alt_dic["identifier"])
- list_ids_and_alter.append(";".join([str(entry["id"])]+list_links))
+ list_articles_ids_and_years.append(year)
- list_articles_ids_to_soft.extend(list_ids)
- list_articles_ids_and_alter_ids_to_soft.extend(list_ids_and_alter)
+ list_articles_ids_to_soft.append(entry["id"])
+ list_articles_ids_and_alter_ids_to_soft.append(
+ ";".join([str(entry["id"])] + list_links)
+ )
- page+=1
+ page += 1
if isinstance(dict_res, dict):
dict_res["references"] = list_articles_ids_to_soft
- # Wrap it in a list to make it iterable for your existing loop
dict_res["references_alt"] = list_articles_ids_and_alter_ids_to_soft
+ dict_res["references_year_alt"] = list_articles_ids_and_years
dict_res = [dict_res]
return dict_res
-def final_xml2(api_source, prefix):
+
+
+def save_xml_to_file(xml_content, file_path):
+ os.makedirs(os.path.dirname(file_path), exist_ok=True)
+ with open(file_path, "w", encoding="utf-8") as file:
+ file.write(xml_content)
+ print(f"XML content saved to {file_path}")
+
+
+def final_xml2(api_source, prefix, output_file_path=None):
headers = {'Accept': 'application/json'}
r = requests.get(api_source, headers=headers, timeout=(10, 60))
if r.status_code == 404:
@@ -131,29 +156,46 @@ def final_xml2(api_source, prefix):
elif isinstance(json["result"], list):
for ent in range(len(json["result"])):
soft_id = json["result"][ent]['id']
- json["result"][ent] = add_references_to_software("https://api.zbmath.org/v1/software/"+str(soft_id), json["result"][ent])
+ json["result"][ent] = add_references_to_software(
+ "https://api.zbmath.org/v1/software/"
+ + str(soft_id), json["result"][ent]
+ )
for result in json["result"]:
if isinstance(result, list):
result = result[0]
- apply_zbmath_api_fixes(result, prefix)
- identifier = result["id"]
- dict_math_entities[identifier] = _illegal_xml_chars_RE.sub("", Converter(wrap="root").build(
- result,
- closed_tags_for=[[], '', [None], None]))
- tags[identifier] = extract_tags(result)
- elif isinstance(result, dict):
- apply_zbmath_api_fixes(result, prefix)
- identifier = result["id"]
- dict_math_entities[identifier] = _illegal_xml_chars_RE.sub("", Converter(wrap="root").build(
- result,
- closed_tags_for=[[], '', [None], None]))
- tags[identifier] = extract_tags(result)
+ apply_zbmath_api_fixes(result, prefix)
+ identifier = result["id"]
+
+ if "references_alt" in result:
+ result["references_alt"] = result["references_alt"]
+ if "references_year_alt" in result:
+ result["references_year_alt"] = result["references_year_alt"]
+
+ xml_converter = Converter(wrap="root")
+ xml_output = _illegal_xml_chars_RE.sub("",
+ xml_converter.build(result, closed_tags_for=[[], '', [None], None]))
+
+ if identifier not in dict_math_entities:
+ dict_math_entities[identifier] = xml_output
+ else:
+ raise Exception(f"Duplicate identifier detected: {identifier}")
+
+ tags[identifier] = extract_tags(result)
+
+ if output_file_path:
+ combined_xml_content = "\n".join(dict_math_entities.values())
+ save_xml_to_file(combined_xml_content, output_file_path)
+
return [dict_math_entities, r.elapsed.total_seconds(), tags]
if __name__ == "__main__":
if "document" in sys.argv[1]:
- prefix="oai:zbmath.org:"
+ prefix = "oai:zbmath.org:"
else:
- prefix="oai:swmath.org:"
- print(final_xml2(sys.argv[1], prefix))
+ prefix = "oai:swmath.org:"
+
+ output_file_path = (os.path
+ .join('../../test/data/software/plain_with_references.xml'))
+
+ result = final_xml2(sys.argv[1], prefix, output_file_path)
diff --git a/test/data/software/Datacite-software-reference.xml b/test/data/software/Datacite-software-reference.xml
index aa45144c..4a2eff16 100644
--- a/test/data/software/Datacite-software-reference.xml
+++ b/test/data/software/Datacite-software-reference.xml
@@ -47,7 +47,7 @@
application/xml
http://crd-legacy.lbl.gov/~xiaoye/SuperLU/
-
+
http://crd-legacy.lbl.gov/~xiaoye/SuperLU/
https://api.zbmath.org/v1/document/2187846
https://api.zbmath.org/v1/document/6042299
@@ -70,10 +70,10 @@
https://api.zbmath.org/v1/document/5167018
https://api.zbmath.org/v1/document/5128211
https://api.zbmath.org/v1/document/5251239
- https://api.zbmath.org/v1/document/6766231
https://api.zbmath.org/v1/document/5244390
- https://api.zbmath.org/v1/document/7099306
+ https://api.zbmath.org/v1/document/6766231
https://api.zbmath.org/v1/document/5706020
+ https://api.zbmath.org/v1/document/7099306
https://api.zbmath.org/v1/document/5762200
https://api.zbmath.org/v1/document/7099163
https://api.zbmath.org/v1/document/7687320
@@ -82,25 +82,25 @@
https://api.zbmath.org/v1/document/5670978
https://api.zbmath.org/v1/document/5969946
https://api.zbmath.org/v1/document/6220134
- https://api.zbmath.org/v1/document/6738142
https://api.zbmath.org/v1/document/6537764
+ https://api.zbmath.org/v1/document/6738142
https://api.zbmath.org/v1/document/7914911
https://api.zbmath.org/v1/document/7099336
https://api.zbmath.org/v1/document/7123718
https://api.zbmath.org/v1/document/7705305
https://api.zbmath.org/v1/document/5880057
https://api.zbmath.org/v1/document/5458476
- https://api.zbmath.org/v1/document/7704378
https://api.zbmath.org/v1/document/6599805
+ https://api.zbmath.org/v1/document/7704378
https://api.zbmath.org/v1/document/5982908
https://api.zbmath.org/v1/document/5784806
https://api.zbmath.org/v1/document/5510606
https://api.zbmath.org/v1/document/7138575
- https://api.zbmath.org/v1/document/6449261
https://api.zbmath.org/v1/document/6669495
+ https://api.zbmath.org/v1/document/6449261
https://api.zbmath.org/v1/document/7055073
- https://api.zbmath.org/v1/document/6910452
https://api.zbmath.org/v1/document/6265830
+ https://api.zbmath.org/v1/document/6910452
https://api.zbmath.org/v1/document/7073637
https://api.zbmath.org/v1/document/6475762
https://api.zbmath.org/v1/document/6908831
@@ -108,11 +108,11 @@
https://api.zbmath.org/v1/document/6280859
https://api.zbmath.org/v1/document/6128531
https://api.zbmath.org/v1/document/5221096
+ https://api.zbmath.org/v1/document/6054722
https://api.zbmath.org/v1/document/7301661
+ https://api.zbmath.org/v1/document/7308040
https://api.zbmath.org/v1/document/7271902
- https://api.zbmath.org/v1/document/6054722
https://api.zbmath.org/v1/document/5827163
- https://api.zbmath.org/v1/document/7308040
https://api.zbmath.org/v1/document/7506624
https://api.zbmath.org/v1/document/5244394
https://api.zbmath.org/v1/document/5187738
@@ -130,8 +130,8 @@
https://api.zbmath.org/v1/document/5801879
https://api.zbmath.org/v1/document/5798197
https://api.zbmath.org/v1/document/7315215
- https://api.zbmath.org/v1/document/7495530
https://api.zbmath.org/v1/document/5693879
+ https://api.zbmath.org/v1/document/7495530
https://api.zbmath.org/v1/document/7539438
https://api.zbmath.org/v1/document/7516896
https://api.zbmath.org/v1/document/7720823
@@ -139,28 +139,28 @@
https://api.zbmath.org/v1/document/7405582
https://api.zbmath.org/v1/document/7437405
https://api.zbmath.org/v1/document/7908572
- https://api.zbmath.org/v1/document/6248322
https://api.zbmath.org/v1/document/7937083
- https://api.zbmath.org/v1/document/5777718
+ https://api.zbmath.org/v1/document/6248322
https://api.zbmath.org/v1/document/7625416
+ https://api.zbmath.org/v1/document/5777718
https://api.zbmath.org/v1/document/7206170
+ https://api.zbmath.org/v1/document/7771268
+ https://api.zbmath.org/v1/document/6669494
https://api.zbmath.org/v1/document/7256640
https://api.zbmath.org/v1/document/5909607
- https://api.zbmath.org/v1/document/6669494
- https://api.zbmath.org/v1/document/7188252
- https://api.zbmath.org/v1/document/7771268
https://api.zbmath.org/v1/document/7031748
+ https://api.zbmath.org/v1/document/7188252
https://api.zbmath.org/v1/document/7235951
https://api.zbmath.org/v1/document/6915848
https://api.zbmath.org/v1/document/7427370
https://api.zbmath.org/v1/document/7860853
https://api.zbmath.org/v1/document/6648376
https://api.zbmath.org/v1/document/7917734
- https://api.zbmath.org/v1/document/6666873
https://api.zbmath.org/v1/document/6994473
+ https://api.zbmath.org/v1/document/6666873
https://api.zbmath.org/v1/document/5538352
https://api.zbmath.org/v1/document/2234457
- 10.1145/779359.779361
+ 10.1145/779359.779361
10.1016/j.cma.2011.09.012
1104.0960
10.1016/j.cam.2008.05.016
@@ -181,8 +181,8 @@
10.1017/S0962492904000200
10.1016/j.compfluid.2005.07.005
10.1137/070707002
- 10.1137/16M1079221
10.1137/050637315
+ 10.1137/16M1079221
10.1007/s10287-008-0080-5
10.1137/18M1181353
10.1016/j.jcp.2010.03.028
@@ -192,8 +192,8 @@
10.1002/nme.4729
10.1017/S0022112010005380
10.1007/s00158-007-0105-7
- 10.1145/2830569
10.1002/nla.1978
+ 10.1145/2830569
10.1007/s10444-024-10176-x
2211.07572
10.1137/17M1153674
@@ -204,10 +204,10 @@
2210.02698
10.1137/090747774
10.1145/1326548.1326550
- 10.1137/21M1433253
- 2107.05613
10.1137/15M1010798
1408.6497
+ 10.1137/21M1433253
+ 2107.05613
10.1016/j.cma.2009.07.012
10.1016/j.jcp.2010.04.049
10.1002/gamm.201490037
@@ -216,12 +216,12 @@
10.1137/140980375
1501.06852
10.1016/j.cma.2015.07.009
+ 10.1016/j.jnnfm.2011.06.006
10.1016/j.cam.2017.11.035
1712.08872
- 10.1016/j.jnnfm.2011.06.006
- 10.1016/j.cam.2013.12.046
10.1016/j.jcp.2018.03.011
1710.02307
+ 10.1016/j.cam.2013.12.046
10.1145/2786977
1404.0447
10.1007/978-3-319-17073-2
@@ -230,10 +230,10 @@
10.1201/9781584888093
10.1016/j.compfluid.2008.10.002
10.1016/j.jcp.2019.04.023
+ 10.1016/j.camwa.2021.01.003
10.1137/18M1189348
1801.09809
10.1007/978-3-642-13872-0_15
- 10.1016/j.camwa.2021.01.003
10.1016/j.jcp.2020.109706
1909.01467
10.1137/050622547
@@ -269,22 +269,22 @@
10.1137/21M1399658
2101.02116
10.1145/3577197
- 10.1137/120883153
10.1007/s00466-024-02460-w
2303.06742
- 10.1016/j.parco.2010.01.003
+ 10.1137/120883153
10.1016/j.jcp.2022.111747
2111.12255
+ 10.1016/j.parco.2010.01.003
10.1016/j.cma.2020.113071
1904.10257
10.1016/j.jcp.2023.112351
2302.09161
10.1002/nme.4727
- 10.1016/j.compfluid.2010.09.033
10.1016/j.camwa.2019.08.019
1812.07167
- 10.1016/j.cma.2018.04.047
+ 10.1016/j.compfluid.2010.09.033
10.1002/nla.2210
+ 10.1016/j.cma.2018.04.047
10.1016/j.camwa.2019.09.012
10.1016/j.enganabound.2017.07.006
10.1016/j.cma.2021.114111
diff --git a/test/data/software/plain_with_references.xml b/test/data/software/plain_with_references.xml
index df1ff406..59ed200f 100644
--- a/test/data/software/plain_with_references.xml
+++ b/test/data/software/plain_with_references.xml
@@ -21,14 +21,14 @@
zbMATH Open Web Interface contents unavailable due to conflicting licenses.
http://crd-legacy.lbl.gov/~xiaoye/SuperLU/
- 2
+ oai:swmath.org:2
orms
SuperLU-DIST
265
- 2187846
+ 2187846
6042299
5534910
5134450
@@ -49,10 +49,10 @@
5167018
5128211
5251239
- 6766231
5244390
- 7099306
+ 6766231
5706020
+ 7099306
5762200
7099163
7687320
@@ -61,25 +61,25 @@
5670978
5969946
6220134
- 6738142
6537764
+ 6738142
7914911
7099336
7123718
7705305
5880057
5458476
- 7704378
6599805
+ 7704378
5982908
5784806
5510606
7138575
- 6449261
6669495
+ 6449261
7055073
- 6910452
6265830
+ 6910452
7073637
6475762
6908831
@@ -87,11 +87,11 @@
6280859
6128531
5221096
+ 6054722
7301661
+ 7308040
7271902
- 6054722
5827163
- 7308040
7506624
5244394
5187738
@@ -109,8 +109,8 @@
5801879
5798197
7315215
- 7495530
5693879
+ 7495530
7539438
7516896
7720823
@@ -118,28 +118,28 @@
7405582
7437405
7908572
- 6248322
7937083
- 5777718
+ 6248322
7625416
+ 5777718
7206170
+ 7771268
+ 6669494
7256640
5909607
- 6669494
- 7188252
- 7771268
7031748
+ 7188252
7235951
6915848
7427370
7860853
6648376
7917734
- 6666873
6994473
+ 6666873
5538352
2234457
- 2187846;10.1145/779359.779361
+ 2187846;10.1145/779359.779361
6042299;10.1016/j.cma.2011.09.012;1104.0960
5534910;10.1016/j.cam.2008.05.016
5134450
@@ -160,8 +160,8 @@
5167018;10.1017/S0962492904000200
5128211;10.1016/j.compfluid.2005.07.005
5251239;10.1137/070707002
- 6766231;10.1137/16M1079221
5244390;10.1137/050637315
+ 6766231;10.1137/16M1079221
5706020;10.1007/s10287-008-0080-5
7099306;10.1137/18M1181353
5762200;10.1016/j.jcp.2010.03.028
@@ -169,19 +169,19 @@
7687320;10.1007/978-3-031-25820-6
5187739;10.1007/s00200-007-0037-x
6669500;10.1002/nme.4729
- 5969946;10.1017/S0022112010005380
5670978
+ 5969946;10.1017/S0022112010005380
6220134;10.1007/s00158-007-0105-7
- 6738142;10.1145/2830569
6537764;10.1002/nla.1978
+ 6738142;10.1145/2830569
7914911;10.1007/s10444-024-10176-x;2211.07572
7099336;10.1137/17M1153674;1710.08779
7123718;10.1137/18M1219370;1810.03315
7705305;10.1137/21M1450422;2210.02698
5880057;10.1137/090747774
5458476;10.1145/1326548.1326550
- 7704378;10.1137/21M1433253;2107.05613
6599805;10.1137/15M1010798;1408.6497
+ 7704378;10.1137/21M1433253;2107.05613
5982908;10.1016/j.cma.2009.07.012
5784806;10.1016/j.jcp.2010.04.049
5510606;10.1002/gamm.201490037
@@ -189,10 +189,10 @@
6669495;10.1002/nme.4711
6449261;10.1137/140980375;1501.06852
7055073;10.1016/j.cma.2015.07.009
- 6910452;10.1016/j.cam.2017.11.035;1712.08872
6265830;10.1016/j.jnnfm.2011.06.006
- 6475762;10.1016/j.cam.2013.12.046
+ 6910452;10.1016/j.cam.2017.11.035;1712.08872
7073637;10.1016/j.jcp.2018.03.011;1710.02307
+ 6475762;10.1016/j.cam.2013.12.046
6908831;10.1145/2786977;1404.0447
6443071;10.1007/978-3-319-17073-2
6280859;10.1134/S1995423913030038
@@ -200,9 +200,9 @@
5221096;10.1201/9781584888093
6054722;10.1016/j.compfluid.2008.10.002
7301661;10.1016/j.jcp.2019.04.023
+ 7308040;10.1016/j.camwa.2021.01.003
7271902;10.1137/18M1189348;1801.09809
5827163;10.1007/978-3-642-13872-0_15
- 7308040;10.1016/j.camwa.2021.01.003
7506624;10.1016/j.jcp.2020.109706;1909.01467
5244394;10.1137/050622547
5187738;10.1007/s00200-007-0036-y
@@ -229,17 +229,17 @@
7405582;10.1051/m2an/2020074;1912.10157
7437405;10.1137/21M1399658;2101.02116
7908572;10.1145/3577197
- 6248322;10.1137/120883153
7937083;10.1007/s00466-024-02460-w;2303.06742
- 5777718;10.1016/j.parco.2010.01.003
+ 6248322;10.1137/120883153
7625416;10.1016/j.jcp.2022.111747;2111.12255
+ 5777718;10.1016/j.parco.2010.01.003
7206170;10.1016/j.cma.2020.113071;1904.10257
7771268;10.1016/j.jcp.2023.112351;2302.09161
6669494;10.1002/nme.4727
- 5909607;10.1016/j.compfluid.2010.09.033
7256640;10.1016/j.camwa.2019.08.019;1812.07167
- 7188252;10.1016/j.cma.2018.04.047
+ 5909607;10.1016/j.compfluid.2010.09.033
7031748;10.1002/nla.2210
+ 7188252;10.1016/j.cma.2018.04.047
7235951;10.1016/j.camwa.2019.09.012
6915848;10.1016/j.enganabound.2017.07.006
7427370;10.1016/j.cma.2021.114111;2101.11649
@@ -250,6 +250,117 @@
6666873;10.1016/j.jcp.2016.06.039
5538352;10.1007/978-3-540-71992-2_17
2234457
+ 2003
+ 2012
+ 2009
+ 2006
+ 2022
+ 2018
+ 2006
+ 2024
+ 2008
+ 2007
+ 2002
+ 2006
+ 2015
+ 2021
+ 2005
+ 2010
+ 2009
+ 2011
+ 2004
+ 2007
+ 2008
+ 2007
+ 2017
+ 2010
+ 2019
+ 2010
+ 2019
+ 2023
+ 2007
+ 2014
+ 2009
+ 2011
+ 2007
+ 2015
+ 2016
+ 2024
+ 2019
+ 2019
+ 2023
+ 2010
+ 2008
+ 2016
+ 2023
+ 2010
+ 2010
+ 2006
+ 2019
+ 2014
+ 2015
+ 2015
+ 2011
+ 2018
+ 2018
+ 2014
+ 2017
+ 2015
+ 2013
+ 2012
+ 2008
+ 2009
+ 2019
+ 2021
+ 2020
+ 2010
+ 2020
+ 2007
+ 2007
+ 2018
+ 2014
+ 2009
+ 2007
+ 2023
+ 2011
+ 2013
+ 2008
+ 2010
+ 2023
+ 2015
+ 2009
+ 2010
+ 2020
+ 2008
+ 2022
+ 2022
+ 2016
+ 2023
+ 2011
+ 2021
+ 2021
+ 2023
+ 2024
+ 2013
+ 2023
+ 2010
+ 2020
+ 2023
+ 2014
+ 2020
+ 2011
+ 2018
+ 2018
+ 2020
+ 2017
+ 2021
+ 2024
+ 2015
+ 2024
+ 2017
+ 2016
+ 2008
+ 2005
4013
MUMPS
@@ -258,26 +369,26 @@
4012
PETSc
-
- 930
- SuperLU
-
4629
SparseMatrix
- 503
- LAPACK
+ 930
+ SuperLU
- 426
- hypre
+ 503
+ LAPACK
679
PARDISO
+
+ 426
+ hypre
+
4028
Trilinos
@@ -302,6 +413,10 @@
4827
mctoolbox
+
+ 23170
+ GitHub
+
4218
ARPACK
@@ -322,10 +437,6 @@
3216
BLAS
-
- 23170
- GitHub
-
3516
deal.ii
@@ -339,4 +450,4 @@
2003
https://zbmath.org/software/2
-
+
\ No newline at end of file
diff --git a/xslt/software/xslt-software-datacite.xslt b/xslt/software/xslt-software-datacite.xslt
index 4f9ce518..3b56e60c 100644
--- a/xslt/software/xslt-software-datacite.xslt
+++ b/xslt/software/xslt-software-datacite.xslt
@@ -47,11 +47,12 @@
-
-
-
-
-
+
+
+
+
+
+