lib/asciidoctor/nist/validate.rb in metanorma-nist-1.2.9 vs lib/asciidoctor/nist/validate.rb in metanorma-nist-1.2.10

- old
+ new

@@ -46,21 +46,32 @@ @log.add("Document Attributes", nil, "#{iteration} is not a recognised iteration") end def series_validate(xmldoc) - series = xmldoc&.at("//bibdata/series/title")&.text or return + series = xmldoc&.at("//bibdata/series[@type = 'main']/title")&.text or return + recognised_series_validate(series) + subseries_validate(series, xmldoc) + end + + def recognised_series_validate(series) found = false SERIES.each { |_, v| found = true if v == series } - found or - @log.add("Document Attributes", nil, - "#{series} is not a recognised series") + found or @log.add("Document Attributes", nil, "#{series} is not a recognised series") end + def subseries_validate(series, xmldoc) + subseries = xmldoc&.at("//bibdata/series[@type = 'secondary']") + csts = series == "NIST Cybersecurity Technical Specification" + subseries && !csts and + @log.add("Document Attributes", nil, "Subseries are not permitted on the series #{series}") + !subseries && csts and + @log.add("Document Attributes", nil, "Subseries are required on the series #{series}") + end + def validate(doc) content_validate(doc) - schema_validate(formattedstr_strip(doc.dup), - File.join(File.dirname(__FILE__), "nist.rng")) + schema_validate(formattedstr_strip(doc.dup), File.join(File.dirname(__FILE__), "nist.rng")) end def introduction_validate(doc) intro = doc.at("//sections/clause/title") intro&.text == "Introduction" or