Class: Metanorma::CollectionRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/metanorma/collection_renderer.rb,
lib/metanorma/collection_fileparse.rb,
lib/metanorma/collection_fileprocess.rb

Overview

XML collection renderer

Defined Under Namespace

Classes: Dummy, PdfOptionsNode

Constant Summary collapse

FORMATS =
%i[html xml doc pdf].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection, folder, options = {}) ⇒ CollectionRenderer

This is only going to render the HTML collection We presuppose that the bibdata of the document is equivalent to that of the collection, and that the flavour gem can sensibly process it. We may need to enhance metadata in the flavour gems isodoc/metadata.rb with collection metadata

Parameters:

  • xml (Metanorma::Collection)

    input XML collection

  • folder (String)

    input folder

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :coverpage (String)

    cover page HTML (Liquid template)

  • :format (Array<Symbol>)

    list of formats (xml,html,doc,pdf)

  • :ourput_folder (String)

    output directory



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/metanorma/collection_renderer.rb', line 24

def initialize(collection, folder, options = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  check_options options
  @xml = Nokogiri::XML collection.to_xml # @xml is the collection manifest
  @lang = @xml&.at(ns("//bibdata/language"))&.text || "en"
  @script = @xml&.at(ns("//bibdata/script"))&.text || "Latn"
  @doctype = doctype
  require "metanorma-#{@doctype}"

  # output processor for flavour
  @isodoc = isodoc

  @outdir = options[:output_folder]
  @coverpage = options[:coverpage]
  @format = options[:format]
  @compile_options = options[:compile] || {}
  @log = options[:log]
  @documents = collection.documents

  # list of files in the collection
  @files = read_files folder
  FileUtils.rm_rf @outdir
  FileUtils.mkdir_p @outdir
end

Class Method Details

.render(col, options = {}) ⇒ Object

Parameters:

Options Hash (options):

  • :coverpage (String)

    cover page HTML (Liquid template)

  • :format (Array<Synbol>)

    list of formats

  • :ourput_folder (Strong)

    output directory



53
54
55
56
57
58
59
# File 'lib/metanorma/collection_renderer.rb', line 53

def self.render(col, options = {})
  folder = File.dirname col.file
  cr = new(col, folder, options)
  cr.files
  cr.concatenate(col, options)
  cr.coverpage if options[:format]&.include?(:html)
end

Instance Method Details

#add_document_suffix(identifier, doc) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/metanorma/collection_fileprocess.rb', line 56

def add_document_suffix(identifier, doc)
  document_suffix = Metanorma::Utils::to_ncname(identifier)
  [%w[* id], %w[* bibitemid], %w[review from],
   %w[review to], %w[index to], %w[xref target],
   %w[callout target]]
    .each do |(tag_name, attribute_name)|
    add_suffix_to_attributes(doc, document_suffix, tag_name, attribute_name)
  end
end

#add_suffix_to_attributes(doc, suffix, tag_name, attribute_name) ⇒ Object



49
50
51
52
53
54
# File 'lib/metanorma/collection_fileprocess.rb', line 49

def add_suffix_to_attributes(doc, suffix, tag_name, attribute_name)
  doc.xpath(ns("//#{tag_name}[@#{attribute_name}]")).each do |elem|
    elem.attributes[attribute_name].value =
      "#{elem.attributes[attribute_name].value}_#{suffix}"
  end
end

#concatenate(col, options) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/metanorma/collection_renderer.rb', line 61

def concatenate(col, options)
  options[:format] << :presentation if options[:format].include?(:pdf)
  options[:format].uniq.each do |e|
    next unless %i(presentation xml).include?(e)

    ext = e == :presentation ? "presentation.xml" : e.to_s
    out = col.clone
    out.directives << "documents-inline"
    out.documents.keys.each do |id|
      next if @files[id][:attachment]

      filename = @files[id][:outputs][e]
      out.documents[id] = Metanorma::Document.raw_file(filename)
    end
    File.open(File.join(@outdir, "collection.#{ext}"), "w:UTF-8") { |f| f.write(out.to_xml) }
  end
  options[:format].include?(:pdf) and
    pdfconv.convert(File.join(@outdir, "collection.presentation.xml"))
end

#copy_file_to_dest(fileref) ⇒ Object



111
112
113
114
115
116
# File 'lib/metanorma/collection_fileprocess.rb', line 111

def copy_file_to_dest(fileref)
  _file, filename = targetfile(fileref, read: true, doc: false)
  dest = File.join(@outdir, fileref[:out_path])
  FileUtils.mkdir_p(File.dirname(dest))
  FileUtils.cp filename, dest
end

#coverpageObject

populate liquid template of ARGV with metadata extracted from collection manifest



140
141
142
143
144
145
146
# File 'lib/metanorma/collection_renderer.rb', line 140

def coverpage
  return unless @coverpage

  File.open(File.join(@outdir, "index.html"), "w:UTF-8") do |f|
    f.write @isodoc.populate_template(File.read(@coverpage))
  end
end

#datauri_encode(docxml) ⇒ Object



79
80
81
82
83
84
# File 'lib/metanorma/collection_fileparse.rb', line 79

def datauri_encode(docxml)
  docxml.xpath(ns("//image")).each do |i|
    i["src"] = Metanorma::Utils::datauri(i["src"])
  end
  docxml
end

#docrefs(elm, builder) ⇒ Object

Parameters:

  • elm (Nokogiri::XML::Element)
  • builder (Nokogiri::XML::Builder)


169
170
171
172
173
174
175
176
177
# File 'lib/metanorma/collection_renderer.rb', line 169

def docrefs(elm, builder)
  elm.xpath(ns("./docref")).each do |d|
    identifier = d.at(ns("./identifier")).text
    link = if d["fileref"] then d["fileref"].sub(/\.xml$/, ".html")
           else d["id"] + ".html"
           end
    builder.li { builder.a identifier, href: link }
  end
end

#doctypeObject

infer the flavour from the first document identifier; relaton does that



123
124
125
126
127
128
129
130
131
132
# File 'lib/metanorma/collection_renderer.rb', line 123

def doctype
  if (docid = @xml&.at(ns("//bibdata/docidentifier/@type"))&.text)
    dt = docid.downcase
  elsif (docid = @xml&.at(ns("//bibdata/docidentifier"))&.text)
    dt = docid.sub(/\s.*$/, "").lowercase
  else return "standoc"
  end
  @registry = Metanorma::Registry.instance
  @registry.alias(dt.to_sym)&.to_s || dt
end

#file_compile(file, filename, identifier) ⇒ Object

compile and output individual file in collection



97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/metanorma/collection_fileprocess.rb', line 97

def file_compile(file, filename, identifier)
  # warn "metanorma compile -x html #{f.path}"
  c = Compile.new
  c.compile file.path, { format: :asciidoc,
                         extension_keys: @format }.merge(@compile_options)
  @files[identifier][:outputs] = {}
  @format.each do |e|
    ext = c.processor.output_formats[e]
    fn = File.basename(filename).sub(/(?<=\.)[^\.]+$/, ext.to_s)
    FileUtils.mv file.path.sub(/\.xml$/, ".#{ext}"), File.join(@outdir, fn)
    @files[identifier][:outputs][e] = File.join(@outdir, fn)
  end
end

#file_entry(docref, identifier, _path) ⇒ Object

rel_path is the source file address, determined relative to the YAML. out_path is the destination file address, with any references outside the working directory (../../…) truncated



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/metanorma/collection_fileprocess.rb', line 37

def file_entry(docref, identifier, _path)
  ret = if docref["fileref"]
          { type: "fileref", ref: @documents[identifier].file,
            rel_path: docref["fileref"],
            out_path: Util::source2dest_filename(docref["fileref"]) }
        else
          { type: "id", ref: docref["id"] }
        end
  ret[:attachment] = docref["attachment"] if docref["attachment"]
  ret
end

#filesObject

process each file in the collection files are held in memory, and altered as postprocessing



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/metanorma/collection_fileprocess.rb', line 120

def files # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  internal_refs = locate_internal_refs
  @files.each do |identifier, x|
    if x[:attachment] then copy_file_to_dest(x)
    else
      file, filename = targetfile(x, read: true)
      file = update_xrefs(file, identifier, internal_refs)
      Tempfile.open(["collection", ".xml"], encoding: "utf-8") do |f|
        f.write(file)
        f.close
        file_compile(f, filename, identifier)
      end
    end
  end
end

#gather_internal_refsObject

gather internal bibitem references



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/metanorma/collection_fileparse.rb', line 178

def gather_internal_refs
  @files.each_with_object({}) do |(_, x), refs|
    next if x[:attachment]

    file, = targetfile(x, read: true)
    Nokogiri::XML(file)
      .xpath(ns("//bibitem[@type = 'internal']/"\
    "docidentifier[@type = 'repository']")).each do |d|
      a = d.text.split(%r{/}, 2)
      a.size > 1 or next
      refs[a[0]] ||= {}
      refs[a[0]][a[1]] = true
    end
  end
end

#indexfile(elm) ⇒ String

single level navigation list, with hierarchical nesting if multiple lists are needed as separate HTML fragments, multiple instances of this function will be needed, and associated to different variables in the call to @isodoc.metadata_init (including possibly an array of HTML fragments)

Parameters:

  • elm (Nokogiri::XML::Element)

Returns:

  • (String)

    XML



187
188
189
190
191
192
193
194
195
196
197
# File 'lib/metanorma/collection_renderer.rb', line 187

def indexfile(elm)
  Nokogiri::HTML::Builder.new do |b|
    b.ul do
      b.li indexfile_title(elm)
      indexfile_docref(elm, b)
      elm.xpath(ns("./manifest")).each do |d|
        b << indexfile(d)
      end
    end
  end.doc.root.to_html
end

#indexfile_docref(elm, builder) ⇒ Object

uses the identifier to label documents; other attributes (title) can be looked up in @files[:bibdata]

Parameters:

  • elm (Nokogiri::XML::Element)
  • builder (Nokogiri::XML::Builder)


161
162
163
164
165
# File 'lib/metanorma/collection_renderer.rb', line 161

def indexfile_docref(elm, builder)
  return "" unless elm.at(ns("./docref"))

  builder.ul { |b| docrefs(elm, b) }
end

#indexfile_title(elm) ⇒ String

Parameters:

  • elm (Nokogiri::XML::Element)

Returns:

  • (String)


150
151
152
153
154
# File 'lib/metanorma/collection_renderer.rb', line 150

def indexfile_title(elm)
  lvl = elm&.at(ns("./level"))&.text&.capitalize
  lbl = elm&.at(ns("./title"))&.text
  "#{lvl}#{lvl && lbl ? ': ' : ''}#{lbl}"
end

#isodocObject

The isodoc class for the metanorma flavour we are using



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/metanorma/collection_renderer.rb', line 106

def isodoc # rubocop:disable Metrics/MethodLength
  x = Asciidoctor.load nil, backend: @doctype.to_sym
  isodoc = x.converter.html_converter(Dummy.new)
  isodoc.i18n_init(@lang, @script) # read in internationalisation
  # create the @meta class of isodoc, with "navigation" set to the index bar
  # extracted from the manifest
  nav = indexfile(@xml.at(ns("//manifest")))
  i18n = isodoc.i18n
  i18n.set(:navigation, nav)
  isodoc.(@lang, @script, i18n)
  # populate the @meta class of isodoc with the various metadata fields
  # native to the flavour; used to populate Liquid
  isodoc.info(@xml, nil)
  isodoc
end

#locate_internal_refsObject

resolve file location for the target of each internal reference



195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/metanorma/collection_fileparse.rb', line 195

def locate_internal_refs
  refs = gather_internal_refs
  @files.keys.reject { |k| @files[k][:attachment] }.each do |identifier|
    locate_internal_refs1(refs, identifier, @files[identifier])
  end
  refs.each do |schema, ids|
    ids.each do |id, key|
      key == true and refs[schema][id] = "Missing:#{schema}:#{id}"
    end
  end
  refs
end

#locate_internal_refs1(refs, identifier, filedesc) ⇒ Object



208
209
210
211
212
213
214
215
216
217
218
# File 'lib/metanorma/collection_fileparse.rb', line 208

def locate_internal_refs1(refs, identifier, filedesc)
  file, _filename = targetfile(filedesc, read: true)
  docxml = Nokogiri::XML(file)
  refs.each do |schema, ids|
    ids.each_key do |id|
      n = docxml.at("//*[@id = '#{id}']") and
        n.at("./ancestor-or-self::*[@type = '#{schema}']") and
        refs[schema][id] = identifier
    end
  end
end

#ns(xpath) ⇒ Object



134
135
136
# File 'lib/metanorma/collection_renderer.rb', line 134

def ns(xpath)
  IsoDoc::Convert.new({}).ns(xpath)
end

#pdfconvObject



81
82
83
84
85
# File 'lib/metanorma/collection_renderer.rb', line 81

def pdfconv
  doctype = @doctype.to_sym
  x = Asciidoctor.load nil, backend: doctype
  x.converter.pdf_converter(PdfOptionsNode.new(doctype, @compile_options))
end

#read_anchors(xml) ⇒ Object

map locality type and label (e.g. “clause” “1”) to id = anchor for a document Note: will only key clauses, which have unambiguous reference label in locality. Notes, examples etc with containers are just plunked against UUIDs, so that their IDs can at least be registered to be tracked as existing.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/metanorma/collection_fileparse.rb', line 10

def read_anchors(xml)
  xrefs = @isodoc.xref_init(@lang, @script, @isodoc, @isodoc.i18n, {})
  xrefs.parse xml
  xrefs.get.each_with_object({}) do |(k, v), ret|
    ret[v[:type]] ||= {}
    index = if v[:container] || v[:label].nil? || v[:label].empty?
              UUIDTools::UUID.random_create.to_s
            else v[:label]
            end
    ret[v[:type]][index] = k
  end
end

#read_files(path) ⇒ Hash{String=>Hash}

hash for each document in collection of document identifier to: document reference (fileref or id), type of document reference, and bibdata entry for that file

Parameters:

  • path (String)

    path to collection

Returns:

  • (Hash{String=>Hash})


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/metanorma/collection_fileprocess.rb', line 15

def read_files(path) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  files = {}
  @xml.xpath(ns("//docref")).each do |d|
    identifier = d.at(ns("./identifier")).text
    files[identifier] = file_entry(d, identifier, path)
    if files[identifier][:attachment]
      files[identifier][:bibdata] = Metanorma::Document
        .attachment_bibitem(identifier).root
    else
      file, _filename = targetfile(files[identifier], read: true)
      xml = Nokogiri::XML(file)
      add_document_suffix(identifier, xml)
      files[identifier][:anchors] = read_anchors(xml)
      files[identifier][:bibdata] = xml.at(ns("//bibdata"))
    end
  end
  files
end

#ref_file(ref, read, doc) ⇒ Array<String, nil>

Parameters:

  • ref (String)
  • read (Boolean)
  • doc (Boolean)

Returns:

  • (Array<String, nil>)


89
90
91
92
93
94
# File 'lib/metanorma/collection_fileprocess.rb', line 89

def ref_file(ref, read, doc)
  file = File.read(ref, encoding: "utf-8") if read
  filename = ref.dup
  filename.sub!(/\.xml$/, ".html") if doc
  [file, filename]
end

#svgmap_resolve(docxml) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/metanorma/collection_fileparse.rb', line 86

def svgmap_resolve(docxml)
  isodoc = IsoDoc::Convert.new({})
  docxml.xpath(ns("//svgmap//eref")).each do |e|
    href = isodoc.eref_target(e)
    next if href == "##{e['bibitemid']}" ||
      href =~ /^#/ && !docxml.at("//*[@id = '#{href.sub(/^#/, '')}']")

    e["target"] = href.strip
    e.name = "link"
    e&.elements&.remove
  end
  Metanorma::Utils::svgmap_rewrite(docxml, "")
end

#targetfile(data, options) ⇒ Array<String, nil>

return file contents + output filename for each file in the collection, given a docref entry so my URL should end with html or pdf or whatever formed relative to YAML file, not input path, relative to calling function

Parameters:

  • data (Hash)

    docref entry

  • read (Boolean)

    read the file in and return it

  • doc (Boolean)

    I am a Metanorma document,

  • relative (Boolean)

    Return output path,

Returns:

  • (Array<String, nil>)


75
76
77
78
79
80
81
82
83
# File 'lib/metanorma/collection_fileprocess.rb', line 75

def targetfile(data, options)
  options = { read: false, doc: true, relative: false }.merge(options)
  path = options[:relative] ? data[:out_path] : data[:ref]
  if data[:type] == "fileref"
    ref_file path, options[:read], options[:doc]
  else
    xml_file data[:id], options[:read]
  end
end

#update_anchor_create_loc(bib, e, docid) ⇒ Object

if there is a crossref to another document, with no anchor, retrieve the anchor given the locality, and insert it into the crossref



164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/metanorma/collection_fileparse.rb', line 164

def update_anchor_create_loc(bib, e, docid)
  ins = e.at(ns("./localityStack")) || return
  type = ins&.at(ns("./locality/@type"))&.text
  ref = ins&.at(ns("./locality/referenceFrom"))&.text
  (anchor = @files[docid][:anchors][type][ref]) || return
  ref_from = Nokogiri::XML::Node.new "referenceFrom", bib
  ref_from.content = anchor.sub(/^_/, "")
  locality = Nokogiri::XML::Node.new "locality", bib
  locality[:type] = "anchor"
  locality.add_child ref_from
  ins << locality
end

#update_anchor_loc(bib, e, docid) ⇒ Object



149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/metanorma/collection_fileparse.rb', line 149

def update_anchor_loc(bib, e, docid)
  loc = e.at(ns(".//locality[@type = 'anchor']")) or
    return update_anchor_create_loc(bib, e, docid)
  document_suffix = Metanorma::Utils::to_ncname(docid)
  ref = loc.at(ns("./referenceFrom")) || return
  anchor = "#{ref.text}_#{document_suffix}"
  return unless @files[docid][:anchors].inject([]) do |m, (_, x)|
    m += x.values
  end.include?(anchor)

  ref.content = anchor
end

#update_anchors(bib, docxml, _id) ⇒ Object

update crossrefences to other documents, to include disambiguating document suffix on id



137
138
139
140
141
142
143
144
145
146
147
# File 'lib/metanorma/collection_fileparse.rb', line 137

def update_anchors(bib, docxml, _id) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
  docid = bib&.at(ns("./docidentifier"))&.text
  docxml.xpath("//xmlns:eref[@citeas = '#{docid}']").each do |e|
    if @files[docid]
      update_anchor_loc(bib, e, docid)
    else
      e << "<strong>** Unresolved reference to document #{docid}, "\
        "id #{e['bibitemid']}</strong>"
    end
  end
end

#update_bibitem(bib, identifier) ⇒ Object

Parameters:

  • bib (Nokogiri::XML::Element)
  • identifier (String)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/metanorma/collection_fileparse.rb', line 34

def update_bibitem(bib, identifier) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  docid = bib&.at(ns("./docidentifier"))&.text
  unless @files[docid]
    error = "[metanorma] Cannot find crossreference to document #{docid} "\
      "in document #{identifier}."
    @log.add("Cross-References", nil, error)
    Util.log(error, :warning)
    return
  end
  id = bib["id"]
  newbib = bib.replace(@files[docid][:bibdata])
  newbib.name = "bibitem"
  newbib["id"] = id
  newbib["hidden"] = "true"
  newbib&.at(ns("./ext"))&.remove
  _file, url = targetfile(@files[docid], relative: true, read: false,
                                         doc: !@files[docid][:attachment])
  uri_node = Nokogiri::XML::Node.new "uri", newbib
  uri_node[:type] = "citation"
  uri_node.content = url
  newbib.at(ns("./docidentifier")).previous = uri_node
end

#update_direct_refs_to_docs(docxml, identifier) ⇒ Object

repo(current-metanorma-collection/ISO 17301-1:2016) replaced by bibdata of “ISO 17301-1:2016” in situ as bibitem. Any erefs to that bibitem id are replaced with relative URL Preferably with anchor, and is a job to realise dynamic lookup of localities.



105
106
107
108
109
110
111
112
113
# File 'lib/metanorma/collection_fileparse.rb', line 105

def update_direct_refs_to_docs(docxml, identifier)
  docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |b|
    docid = b&.at(ns("./docidentifier[@type = 'repository']"))&.text
    next unless docid && %r{^current-metanorma-collection/}.match(docid)

    update_bibitem(b, identifier)
    update_anchors(b, docxml, docid)
  end
end

#update_indirect_refs_to_docs(docxml, internal_refs) ⇒ Object

Resolve erefs to a container of ids in another doc, to an anchor eref (direct link)



117
118
119
120
121
122
123
# File 'lib/metanorma/collection_fileparse.rb', line 117

def update_indirect_refs_to_docs(docxml, internal_refs)
  internal_refs.each do |schema, ids|
    ids.each do |id, file|
      update_indirect_refs_to_docs1(docxml, schema, id, file)
    end
  end
end

#update_indirect_refs_to_docs1(docxml, schema, id, file) ⇒ Object



125
126
127
128
129
130
131
132
133
# File 'lib/metanorma/collection_fileparse.rb', line 125

def update_indirect_refs_to_docs1(docxml, schema, id, file)
  docxml.xpath(ns("//eref[@bibitemid = '#{schema}_#{id}']")).each do |e|
    e["citeas"] = file
  end
  docid = docxml.at(ns("//bibitem[@id = '#{schema}_#{id}']/"\
                       "docidentifier[@type = 'repository']")) or return
  docid.children = "current-metanorma-collection/#{file}"
  docid.previous = "<docidentifier type='X'>#{file}</docidentifier>"
end

#update_xrefs(file, identifier, internal_refs) ⇒ String

Resolves direct links to other files in collection (repo(current-metanorma-collection/x), and indirect links to other files in collection (bibitem[@type = ‘internal’] pointing to a file anchor in another file in the collection)

Parameters:

  • file (String)

    XML content

  • identifier (String)

    docid

  • internal_refs (Hash{String=>Hash{String=>String}] schema name to anchor to filename)

    nternal_refs [HashString=>Hash{String=>String] schema name to anchor to filename

Returns:

  • (String)

    XML content



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/metanorma/collection_fileparse.rb', line 66

def update_xrefs(file, identifier, internal_refs)
  docxml = Nokogiri::XML(file)
  update_indirect_refs_to_docs(docxml, internal_refs)
  add_document_suffix(identifier, docxml)
  update_direct_refs_to_docs(docxml, identifier)
  svgmap_resolve(datauri_encode(docxml))
  docxml.xpath(ns("//references[not(./bibitem[not(@hidden) or "\
                  "@hidden = 'false'])]")).each do |f|
    f["hidden"] = "true"
  end
  docxml.to_xml
end

#xml_file(id, read) ⇒ Array<String, nil>

Parameters:

  • id (String)
  • read (Boolean)

Returns:

  • (Array<String, nil>)


26
27
28
29
30
# File 'lib/metanorma/collection_fileparse.rb', line 26

def xml_file(id, read)
  file = @xml.at(ns("//doc-container[@id = '#{id}']")).to_xml if read
  filename = "#{id}.html"
  [file, filename]
end