lib/metanorma/ieee/validate_section.rb in metanorma-ieee-0.0.1 vs lib/metanorma/ieee/validate_section.rb in metanorma-ieee-0.0.2

- old
+ new

@@ -56,10 +56,11 @@ def sections_sequence_validate(root) names, n = sections_sequence_validate_start(root) names, n = sections_sequence_validate_body(names, n) sections_sequence_validate_end(names, n) + bibliography_validate(root) end def sections_sequence_validate_start(root) names = root.xpath(SECTIONS_XPATH) names = seqcheck(names, SEQ[0][:msg], SEQ[0][:val]) @@ -84,17 +85,10 @@ end end elem&.at("./self::references[@normative = 'true']") || @log.add("Style", nil, "Document must include (references) "\ "Normative References") - elem = names&.shift - elem&.at("./self::references[@normative = 'false']") || - @log.add("Style", elem, - "Final section must be (references) Bibliography") - names.empty? || - @log.add("Style", elem, - "There are sections after the final Bibliography") end # Style manual 13.1 def subclause_validate(root) root.xpath("//clause/clause/clause/clause/clause/clause") @@ -111,9 +105,22 @@ title = c.at("./title") location = c["id"] || "#{c.text[0..60]}..." location += ":#{title.text}" if c["id"] && !title.nil? @log.add("Style", nil, "#{location}: subclause is only child") end + end + + # Style manual 19.1 + def bibliography_validate(root) + bib = root.at("//references[@normative = 'false']") or return + if annex = bib.at(".//ancestor::annex") + prec = annex.xpath("./preceding-sibling::annex") + foll = annex.xpath("./following-sibling::annex") + valid = prec.empty? || foll.empty? + else valid = false + end + valid or @log.add("Style", bib, "Bibliography must be either the first "\ + "or the last document annex") end end end end