-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crossmark #465
base: master
Are you sure you want to change the base?
Crossmark #465
Changes from 16 commits
ae138fa
80c58fc
0a443b6
6324e5e
75b8f89
47c57b0
6af2832
977442c
3c75217
68b3fe2
6712578
dc4c46e
baaffd8
bc6036d
e990ef5
db301b8
0246f96
b15e7e7
a7dfaab
5b161c9
7402902
628d165
9a357e2
f28dfd8
94abd13
3b5fdde
f3e1b8c
cb68638
7e2d990
ea002d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
article_titles, | ||
article_doi_with_lang, | ||
article_citations, | ||
related_articles, | ||
) | ||
|
||
SUPPLBEG_REGEX = re.compile(r'^0 ') | ||
|
@@ -1401,6 +1402,196 @@ def xml_crossref_pid_pipe(xml_crossref, xml_tree): | |
xml_crossref.find('./body/journal/journal_article').append(publisher_item) | ||
|
||
|
||
def xml_crossref_crossmark_pipe(xml_crossref): | ||
""" | ||
Adiciona o elemento 'crossmark' ao XML Crossref. | ||
|
||
Parameters | ||
---------- | ||
xml_crossref : lxml.etree._Element | ||
Elemento XML no padrão CrossRef em construção | ||
|
||
Returns | ||
------- | ||
None | ||
""" | ||
crossmark = ET.Element("crossmark") | ||
article_el = xml_crossref.find('./body/journal/journal_article') | ||
article_el.append(crossmark) | ||
|
||
|
||
def xml_crossref_crossmark_policy_pipe(xml_crossref, data): | ||
""" | ||
Adiciona o elemento 'crossmark_policy' ao XML Crossref. | ||
|
||
Parameters | ||
---------- | ||
xml_crossref : lxml.etree._Element | ||
Elemento XML no padrão CrossRef em construção | ||
|
||
data : dict | ||
Dicionário com dados suplementares para a criação do xml_crossref como, por exemplo: | ||
data = { | ||
"crossmark_policy": "10.5555/crossmark_policy" | ||
} | ||
|
||
Returns | ||
------- | ||
None | ||
""" | ||
policy_value = data.get("crossmark_policy") | ||
|
||
if policy_value: | ||
crossmark_el = xml_crossref.find('./body/journal/journal_article/crossmark') | ||
policy_el = ET.Element("crossmark_policy") | ||
policy_el.text = policy_value | ||
crossmark_el.append(policy_el) | ||
|
||
|
||
def xml_crossref_crossmark_domains_pipe(xml_crossref, data): | ||
""" | ||
Adiciona o elemento 'crossmark_domains' ao XML Crossref. | ||
|
||
Parameters | ||
---------- | ||
xml_crossref : lxml.etree._Element | ||
Elemento XML no padrão CrossRef em construção | ||
|
||
data : dict | ||
Dicionário com dados suplementares para a criação do xml_crossref como, por exemplo: | ||
data = { | ||
"crossmark_domains": ["psychoceramics.labs.crossref.org"], | ||
"crossmark_domain_exclusive": "false" | ||
} | ||
|
||
Returns | ||
------- | ||
None | ||
""" | ||
crossmark_domains = data.get("crossmark_domains") | ||
crossmark_domain_exclusive = data.get("crossmark_domain_exclusive") | ||
|
||
crossmark_el = xml_crossref.find('./body/journal/journal_article/crossmark') | ||
|
||
if crossmark_domains: | ||
crossmark_domains_el = ET.Element("crossmark_domains") | ||
for crossmark_domain_value in crossmark_domains: | ||
crossmark_domain_el = ET.Element("crossmark_domain") | ||
domain_el = ET.Element("domain") | ||
domain_el.text = crossmark_domain_value | ||
crossmark_domain_el.append(domain_el) | ||
crossmark_domains_el.append(crossmark_domain_el) | ||
crossmark_el.append(crossmark_domains_el) | ||
|
||
if crossmark_domain_exclusive: | ||
crossmark_domain_exclusive_el = ET.Element("crossmark_domain_exclusive") | ||
crossmark_domain_exclusive_el.text = crossmark_domain_exclusive | ||
crossmark_el.append(crossmark_domain_exclusive_el) | ||
|
||
|
||
def xml_crossref_crossmark_updates_pipe(xml_crossref, xml_tree): | ||
""" | ||
Adiciona o elemento 'update' ao XML Crossref se houver um DOI de atualização. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Rossi-Luciano coloca exemplo de como deve ficar o updates There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
Parameters | ||
---------- | ||
xml_crossref : lxml.etree._Element | ||
Elemento XML no padrão CrossRef em construção | ||
|
||
xml_tree : lxml.etree._Element | ||
Elemento XML no padrão SciELO com os dados sobre atualizações | ||
|
||
Returns | ||
------- | ||
None | ||
""" | ||
# Obter informações necessárias do XML SciELO | ||
update_type = article_and_subarticles.ArticleAndSubArticles(xml_tree).main_article_type | ||
update_doi = [item.get('href') for item in related_articles.RelatedItems(xml_tree).related_articles][0] | ||
|
||
if update_doi: | ||
update_el = ET.Element("update") | ||
update_el.text = update_doi | ||
update_el.set("type", update_type) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Rossi-Luciano suspeito que o update_type é do related-article. Se o artigo em que estou do XML é um artigo e tem related-article para errata, o update_type é errata e não "artigo". Sim ou não? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Vou compartilhar aqui minhas impressões sobre a lógica do Crossmark... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Veja alguns exemplo encontrados no link anterior: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Rossi-Luciano conforme eu havia comentado sobre
é um "defeito" do XML, pois deveria haver esta indicação que impedirá de gerar corretamente o XML com crossmark. Então, considere que sim em research-article, quando houver errata, deve haver também o related-article indicando a errata. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Rossi-Luciano os valores de type são valores controlados. Verifique se está considerando corretamente: https://data.crossref.org/schemas/common5.3.1.xsd. Busque por There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Rossi-Luciano Na função que adiciona o elemento {
"related-articles": [
{"related-article-type": "", "href": "", "date": ""},
{"related-article-type": "", "href": "", "date": ""},
]} Ou seja, a função deve montar update com os dados do XML e os dados passados por parâmetros There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
update_el.set("label", update_type.capitalize()) | ||
|
||
# Verificar se já existe um elemento 'updates' no XML Crossref | ||
crossmark_el = xml_crossref.find('./body/journal/journal_article/crossmark') | ||
updates_el = crossmark_el.find('updates') | ||
|
||
if updates_el is None: | ||
updates_el = ET.Element("updates") | ||
crossmark_el.append(updates_el) | ||
|
||
updates_el.append(update_el) | ||
|
||
|
||
def xml_crossref_crossmark_custom_metadata_pipe(xml_crossref, xml_tree, data): | ||
""" | ||
Adiciona o elemento 'custom_metadata' ao xml_crossref. | ||
|
||
Parameters | ||
---------- | ||
xml_crossref : lxml.etree._Element | ||
Elemento XML no padrão CrossRef em construção | ||
|
||
xml_tree : lxml.etree._Element | ||
Elemento XML no padrão SciELO com os dados sobre atualizações | ||
|
||
data : dict | ||
Dicionário com dados suplementares para a criação do xml_crossref como, por exemplo: | ||
data = { | ||
"assertions": [ | ||
{ | ||
"name": "remorse", | ||
"label": "Level of Remorse", | ||
"group_name": "publication_notes", | ||
"group_label": "Publication Notes", | ||
"text": "90%" | ||
} | ||
] | ||
} | ||
|
||
Returns | ||
------- | ||
None | ||
""" | ||
history = dates.ArticleDates(xml_tree).history_dates_dict | ||
|
||
for order, item in enumerate(history): | ||
event = history[item] | ||
data.get("assertions").insert(order, | ||
{ | ||
"name": event.get("type"), | ||
"label": event.get("type").capitalize(), | ||
"group_name": "publication_history", | ||
"group_label": "Publication History", | ||
"order": str(order), | ||
"text": '-'.join([event.get("year"), event.get("month"), event.get("day")]) | ||
} | ||
) | ||
|
||
assertions = data.get("assertions") | ||
|
||
if assertions: | ||
crossmark_el = xml_crossref.find('./body/journal/journal_article/crossmark') | ||
custom_metadata_el = ET.Element("custom_metadata") | ||
|
||
for assertion in assertions: | ||
text = assertion.get("text") | ||
if text: | ||
assertion_el = ET.Element("assertion") | ||
assertion_el.text = text | ||
attributes = ["name", "label", "group_name", "group_label", "order"] | ||
for attr in attributes: | ||
value = assertion.get(attr) | ||
if value: | ||
assertion_el.set(attr, value) | ||
custom_metadata_el.append(assertion_el) | ||
|
||
crossmark_el.append(custom_metadata_el) | ||
|
||
|
||
def xml_crossref_elocation_pipe(xml_crossref, xml_tree): | ||
""" | ||
Adiciona o elemento 'item_number' ao xml_crossref. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rossi-Luciano perfeito! Eu acredito que sim este dado é externo ao XML SPS, logo deve ser informado via um dicionário.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK @robertatakenaka