Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions grammars/basicdoc.rng
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@
<data type="ID"/>
</attribute>
<attribute name="reviewer"/>
<optional>
<attribute name="type"/>
</optional>
<optional>
<attribute name="date">
<data type="dateTime"/>
Expand Down
124 changes: 71 additions & 53 deletions grammars/biblio.rng
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<text/>
</element>
</define>
<define name="LocalizedString1">
<define name="LocalizedStringAttrs">
<optional>
<!-- multiple languages and scripts possible: comma delimit them if so -->
<attribute name="language"/>
Expand All @@ -106,6 +106,10 @@
<optional>
<attribute name="script"/>
</optional>
</define>
<define name="LocalizedString1">
<!-- multiple languages and scripts possible: comma delimit them if so -->
<ref name="LocalizedStringAttrs"/>
<text/>
</define>
<define name="LocalizedString">
Expand Down Expand Up @@ -142,16 +146,8 @@
<ref name="LocalizedStringOrXsAny"/>
</define>
<define name="LocalizedStringOrXsAny1">
<optional>
<!-- multiple languages and scripts possible: comma delimit them if so -->
<attribute name="language"/>
</optional>
<optional>
<attribute name="locale"/>
</optional>
<optional>
<attribute name="script"/>
</optional>
<!-- multiple languages and scripts possible: comma delimit them if so -->
<ref name="LocalizedStringAttrs"/>
<oneOrMore>
<choice>
<text/>
Expand Down Expand Up @@ -208,7 +204,10 @@
</define>
<define name="roledescription">
<element name="description">
<ref name="FormattedString"/>
<ref name="LocalizedStringAttrs"/>
<oneOrMore>
<ref name="TextElement"/>
</oneOrMore>
</element>
</define>
<define name="person">
Expand Down Expand Up @@ -333,34 +332,40 @@
</define>
<define name="affiliationdescription">
<element name="description">
<ref name="FormattedString"/>
<ref name="LocalizedStringAttrs"/>
<oneOrMore>
<ref name="TextElement"/>
</oneOrMore>
</element>
</define>
<define name="organization">
<element name="organization">
<oneOrMore>
<ref name="orgname"/>
</oneOrMore>
<zeroOrMore>
<ref name="subdivision"/>
</zeroOrMore>
<optional>
<ref name="abbreviation"/>
</optional>
<zeroOrMore>
<ref name="uri"/>
</zeroOrMore>
<zeroOrMore>
<ref name="org-identifier"/>
</zeroOrMore>
<zeroOrMore>
<ref name="contact"/>
</zeroOrMore>
<optional>
<ref name="logo"/>
</optional>
<ref name="OrganizationType"/>
</element>
</define>
<define name="OrganizationType">
<oneOrMore>
<ref name="orgname"/>
</oneOrMore>
<zeroOrMore>
<ref name="subdivision"/>
</zeroOrMore>
<optional>
<ref name="abbreviation"/>
</optional>
<zeroOrMore>
<ref name="uri"/>
</zeroOrMore>
<zeroOrMore>
<ref name="org-identifier"/>
</zeroOrMore>
<zeroOrMore>
<ref name="contact"/>
</zeroOrMore>
<optional>
<ref name="logo"/>
</optional>
</define>
<define name="orgname">
<element name="name">
<choice>
Expand All @@ -371,10 +376,10 @@
</define>
<define name="subdivision">
<element name="subdivision">
<choice>
<ref name="LocalizedString"/>
<ref name="NameWithVariants"/>
</choice>
<optional>
<attribute name="type"/>
</optional>
<ref name="OrganizationType"/>
</element>
</define>
<define name="logo">
Expand Down Expand Up @@ -894,7 +899,9 @@
</define>
<define name="formattedref">
<element name="formattedref">
<ref name="FormattedString"/>
<oneOrMore>
<ref name="TextElement"/>
</oneOrMore>
</element>
</define>
<define name="license">
Expand Down Expand Up @@ -939,7 +946,10 @@
<optional>
<attribute name="type"/>
</optional>
<ref name="FormattedString"/>
<ref name="LocalizedStringAttrs"/>
<zeroOrMore>
<ref name="TextElement"/>
</zeroOrMore>
</define>
<!-- TitleType = ( "alternative" | "original" | "unofficial" | "subtitle" | "main" ) -->
<define name="TypedUri">
Expand Down Expand Up @@ -1030,16 +1040,10 @@
<data type="boolean"/>
</attribute>
</optional>
<optional>
<attribute name="language"/>
</optional>
<optional>
<attribute name="locale"/>
</optional>
<optional>
<attribute name="script"/>
</optional>
<text/>
<ref name="LocalizedStringAttrs"/>
<oneOrMore>
<ref name="TextElement"/>
</oneOrMore>
</element>
</define>
<define name="docnumber">
Expand Down Expand Up @@ -1264,12 +1268,23 @@
<optional>
<attribute name="type"/>
</optional>
<ref name="FormattedString"/>
<ref name="LocalizedStringAttrs"/>
<oneOrMore>
<ref name="TextElement"/>
</oneOrMore>
</element>
</define>
<define name="bibabstract">
<element name="abstract">
<ref name="FormattedString"/>
<ref name="LocalizedStringAttrs"/>
<choice>
<oneOrMore>
<ref name="BasicBlock"/>
</oneOrMore>
<oneOrMore>
<ref name="TextElement"/>
</oneOrMore>
</choice>
</element>
</define>
<define name="copyright">
Expand Down Expand Up @@ -1374,7 +1389,10 @@
</attribute>
<optional>
<element name="description">
<ref name="FormattedString"/>
<ref name="LocalizedStringAttrs"/>
<oneOrMore>
<ref name="TextElement"/>
</oneOrMore>
</element>
</optional>
<element name="bibitem">
Expand Down
9 changes: 4 additions & 5 deletions lib/relaton_cen/scrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def fetch_ics(doc)
# @return [Array<Hash>]
def fetch_abstract(doc)
content = doc.at("//tr[th[.='Abstract/Scope']]/td")
[{ content: content.text, language: "en", script: "Latn" }]
[RelatonBib::Abstract.new(content: content.text, language: "en", script: "Latn")]
end

# Fetch docid.
Expand Down Expand Up @@ -121,8 +121,7 @@ def fetch_relations(doc) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
else t.downcase
end
rt.xpath("td/a").each do |r|
fref = RelatonBib::FormattedRef.new(content: r.text, language: "en",
script: "Latn")
fref = RelatonBib::FormattedRef.new(r.text)
link = fetch_link HitCollection::DOMAIN + r[:href]
bibitem = RelatonBib::BibliographicItem.new(
formattedref: fref, type: "standard", link: link,
Expand All @@ -137,7 +136,7 @@ def fetch_relations(doc) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
# @return [RelatonBib::TypedTitleStringCollection]
def fetch_titles(doc)
te = doc.at("//tr[th[.='Title']]/td").text.strip
RelatonBib::TypedTitleString.from_string te, "en", "Latn"
RelatonBib::TypedTitleString.from_string te, lang: "en", script: "Latn"
end

# Fetch dates
Expand Down Expand Up @@ -183,7 +182,7 @@ def fetch_link(url)
# @return [Array<Hash>]
def fetch_copyright(doc)
date = doc.at("//tr[th[.='date of Availability (DAV)']]/td").text
owner = owner_entity
owner = RelatonBib::Organization.new(**owner_entity)
from = date.match(/^\d{4}/).to_s
[{ owner: [owner], from: from }]
end
Expand Down
38 changes: 18 additions & 20 deletions lib/relaton_cen/xml_parser.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
module RelatonCen
class XMLParser < RelatonIsoBib::XMLParser
class << self
private
module XMLParser
include RelatonIsoBib::XMLParser
extend self
# Override RelatonBib::XMLParser#item_data method.
# @param isoitem [Nokogiri::XML::Element]
# @returtn [Hash]
# def item_data(isoitem)
# data = super
# ext = isoitem.at "./ext"
# return data unless ext

# Override RelatonBib::XMLParser#item_data method.
# @param isoitem [Nokogiri::XML::Element]
# @returtn [Hash]
# def item_data(isoitem)
# data = super
# ext = isoitem.at "./ext"
# return data unless ext
# data[:price_code] = ext.at("./price-code")&.text
# data[:cen_processing] = ext.at("./cen-processing")&.text
# data
# end

# data[:price_code] = ext.at("./price-code")&.text
# data[:cen_processing] = ext.at("./cen-processing")&.text
# data
# end

# @param item_hash [Hash]
# @return [RelatonCen::BibliographicItem]
def bib_item(item_hash)
BibliographicItem.new(**item_hash)
end
# @param item_hash [Hash]
# @return [RelatonCen::BibliographicItem]
def bib_item(item_hash)
BibliographicItem.new(**item_hash)
end
end
end
Loading