-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Appending of the identfier and and id term to xml schema. enriching i…
…nstruction in READ.me for install. editing requirements.txt for install dependencies
- Loading branch information
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# python-zbMathRest2Oai | ||
Read data from the zbMATH Open API https://api.zbmath.org/docs and feed it to the OAI-PMH server https://oai.portal.mardi4nfdi.de/oai/ | ||
|
||
Hint for a proper installation: | ||
|
||
_ point to the directory | ||
_ execute "pip install -e requirements.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,44 @@ | ||
import swagger_client | ||
from zbmath_rest2oai.xml_writer import create_document | ||
from xml.dom import minidom | ||
|
||
api_instance = swagger_client.DocumentApi(swagger_client.ApiClient()) | ||
res = api_instance.get_document_by_zbmath_id_document_id_get(id="6383667") | ||
doc = res.result | ||
print(create_document(doc).toprettyxml()) | ||
xmld = create_document(doc) | ||
|
||
|
||
ron = xmld.createElement("oai_zb_preview:zbmath") | ||
ron.setAttributeNS( | ||
"xmls", | ||
"xmlns:oai_zb_preview", | ||
"https://zbmath.org/OAI/2.0/oai_zb_preview/", | ||
) | ||
ron.setAttributeNS( | ||
"xmls", | ||
"xmlns:zbmath", | ||
"https://zbmath.org/zbmath/elements/1.0/", | ||
) | ||
ron.setAttributeNS( | ||
"xmls", | ||
"xmlns:xsi", | ||
"http://www.w3.org/2001/XMLSchema-instance", | ||
) | ||
|
||
def append_text_child(xmld, parent, name, value): | ||
""" | ||
Creates new text node and appends it to parent | ||
:param xmld: | ||
:param parent: the node to append to | ||
:param name: | ||
:param value: | ||
""" | ||
x_elem = xmld.createElement(f"zbmath:{0}".format(name)) | ||
text = xmld.createTextNode(str(value)) | ||
x_elem.appendChild(text) | ||
parent.appendChild(x_elem) | ||
return parent | ||
|
||
final_xml = append_text_child(xmld, ron, 'id', (res.result.id)) | ||
|
||
print(final_xml.toprettyxml()) |