Skip to content

Commit

Permalink
fix crossrefxml reference parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mfenner committed May 15, 2024
1 parent ff814e6 commit 087289f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var versionCmd = &cobra.Command{
Short: "Print the version number of commonmeta",
Long: `All software has versions. This is commonmeta's`,
Run: func(cmd *cobra.Command, args []string) {
cmd.Println("Commonmeta v0.3.13 -- HEAD")
cmd.Println("Commonmeta v0.3.14 -- HEAD")
},
}

Expand Down
33 changes: 19 additions & 14 deletions crossrefxml/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -1116,18 +1116,24 @@ func Read(query Query) (commonmeta.Data, error) {

if len(citationList.Citation) > 0 {
for _, v := range citationList.Citation {
reference := commonmeta.Reference{
Key: v.Key,
ID: doiutils.NormalizeDOI(v.DOI.Text),
Title: v.ArticleTitle,
PublicationYear: v.CYear,
Unstructured: v.UnstructedCitation,
var id string
if v.DOI != nil {
id = doiutils.NormalizeDOI(v.DOI.Text)
}
containsKey := slices.ContainsFunc(data.References, func(e commonmeta.Reference) bool {
return e.Key != "" && e.Key == reference.Key
})
if !containsKey {
data.References = append(data.References, reference)
if id != "" {
reference := commonmeta.Reference{
Key: v.Key,
ID: id,
Title: v.ArticleTitle,
PublicationYear: v.CYear,
Unstructured: v.UnstructedCitation,
}
containsKey := slices.ContainsFunc(data.References, func(e commonmeta.Reference) bool {
return e.Key != "" && e.Key == reference.Key
})
if !containsKey {
data.References = append(data.References, reference)
}
}
}
}
Expand Down Expand Up @@ -1309,17 +1315,16 @@ func GetContributors(contrib Contributors) ([]commonmeta.Contributor, error) {

if len(contrib.PersonName) > 0 {
for _, v := range contrib.PersonName {
fmt.Print(v.Affiliations)
var ID string
if v.GivenName != "" || v.Surname != "" {
if v.ORCID != "" {
ID, _ = utils.NormalizeURL(v.ORCID, true, false) // enforce HTTPS
}
}
Type := "Person"
if len(v.Affiliations.Institution) > 0 || v.Affiliation != "" {
if v.Affiliations != nil || v.Affiliation != "" {
var affiliations []*commonmeta.Affiliation
if len(v.Affiliations.Institution) > 0 {
if v.Affiliations != nil {
for _, i := range v.Affiliations.Institution {
if i.InstitutionName != "" {
if i.InstitutionID != nil && i.InstitutionID.Text != "" {
Expand Down

0 comments on commit 087289f

Please sign in to comment.