lib/metanorma/modspec/reqt_label.rb in mn-requirements-0.1.0 vs lib/metanorma/modspec/reqt_label.rb in mn-requirements-0.1.1
- old
+ new
@@ -63,11 +63,12 @@
def reqt_ids(docxml)
docxml.xpath(ns("//requirement | //recommendation | //permission"))
.each_with_object({}) do |r, m|
id = r.at(ns("./identifier")) or next
- m[id.text] = r["id"]
+ m[id.text] =
+ { id: r["id"], lbl: @xrefs.anchor(r["id"], :xref, false) }
end
end
def reqt_links_test(docxml)
docxml.xpath(ns("//requirement | //recommendation | //permission"))
@@ -75,11 +76,11 @@
next unless %w(conformanceclass
verification).include?(r["type"])
subj = r.at(ns("./classification[tag = 'target']/value"))
id = r.at(ns("./identifier")) or next
- lbl = @xrefs.anchor(@reqt_ids[id.text.strip], :xref, false)
+ lbl = @xrefs.anchor(@reqt_ids[id.text.strip][:id], :xref, false)
next unless subj && lbl
m[subj.text] = { lbl: lbl, id: r["id"] }
end
end
@@ -96,11 +97,11 @@
id = r.at(ns("./identifier")) or next
r.xpath(ns("./requirement | ./recommendation | ./permission"))
.each do |r1|
id1 = r1.at(ns("./identifier")) or next
- lbl = @xrefs.anchor(@reqt_ids[id.text.strip], :xref, false)
+ lbl = @xrefs.anchor(@reqt_ids[id.text.strip][:id], :xref, false)
next unless lbl
m[id1.text] = { lbl: lbl, id: r["id"] }
end
end
@@ -111,10 +112,10 @@
"<xref target='#{test[:id]}'>#{test[:lbl]}</xref>"
end
def recommendation_id(ident)
test = @reqt_ids[ident&.strip] or return ident&.strip
- "<xref target='#{test}'>#{ident.strip}</xref>"
+ "<xref target='#{test[:id]}'>#{test[:lbl]}</xref>"
end
end
end
end