Skip to content

Commit

Permalink
jstor: authors stored in string-name
Browse files Browse the repository at this point in the history
  • Loading branch information
miku committed Apr 1, 2015
1 parent 0827192 commit 16ca156
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions jats/article.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ type Article struct {
Value string `xml:",chardata"`
}
}
StringName struct {
XMLName xml.Name `xml:"string-name"`
Surname struct {
XMLName xml.Name `xml:"surname"`
Value string `xml:",chardata"`
}
GivenNames struct {
XMLName xml.Name `xml:"given-names"`
Value string `xml:",chardata"`
}
}
} `xml:"contrib"`
}
Categories struct {
Expand Down
13 changes: 13 additions & 0 deletions jats/jstor/jstor.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ func (article *Article) Identifiers() (jats.Identifiers, error) {
return jats.Identifiers{DOI: doi, URL: locator, RecordID: recordID}, nil
}

// Authors returns the authors as slice.
func (article *Article) Authors() []finc.Author {
var authors []finc.Author
group := article.Front.Article.ContribGroup
for _, contrib := range group.Contrib {
authors = append(authors, finc.Author{
LastName: contrib.StringName.Surname.Value,
FirstName: contrib.StringName.GivenNames.Value})
}
return authors
}

// ToInternalSchema converts an article into an internal schema.
func (article *Article) ToIntermediateSchema() (*finc.IntermediateSchema, error) {
output, err := article.Article.ToIntermediateSchema()
Expand All @@ -106,6 +118,7 @@ func (article *Article) ToIntermediateSchema() (*finc.IntermediateSchema, error)
output.RecordID = ids.RecordID
output.URL = append(output.URL, ids.URL)

output.Authors = article.Authors()
output.Format = Format
output.MegaCollection = SourceName
output.SourceID = SourceID
Expand Down

0 comments on commit 16ca156

Please sign in to comment.