Skip to content

Commit

Permalink
Appending of the identfier and and id term to xml schema. enriching i…
Browse files Browse the repository at this point in the history
…nstruction in READ.me for install. editing requirements.txt for install dependencies
  • Loading branch information
Mazztok45 committed Nov 3, 2023
1 parent 3c717c4 commit 39277a2
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
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"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.
39 changes: 38 additions & 1 deletion src/zbmath_rest2oai/getWithSwagger.py
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())

0 comments on commit 39277a2

Please sign in to comment.