Class: IsoDoc::Xref
- Inherits:
 - 
      Object
      
        
- Object
 - IsoDoc::Xref
 
 
- Defined in:
 - lib/isodoc/xref.rb
 
Constant Summary
Constants included from IsoDoc::XrefGen::Sections
IsoDoc::XrefGen::Sections::ISO_PUBLISHER_XPATH, IsoDoc::XrefGen::Sections::SUBCLAUSES
Constants included from IsoDoc::XrefGen::Blocks
IsoDoc::XrefGen::Blocks::CHILD_EXAMPLES_XPATH, IsoDoc::XrefGen::Blocks::CHILD_NOTES_XPATH, IsoDoc::XrefGen::Blocks::CHILD_SECTIONS, IsoDoc::XrefGen::Blocks::FIRST_LVL_REQ, IsoDoc::XrefGen::Blocks::NUMBERED_BLOCKS, IsoDoc::XrefGen::Blocks::SECTIONS_XPATH
Instance Method Summary collapse
- #anchor(id, lbl, warning = true) ⇒ Object
 - #get ⇒ Object
 - 
  
    
      #initialize(lang, script, klass, i18n, options = {})  ⇒ Xref 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Xref.
 - #l10n(text, lang = @lang, script = @script) ⇒ Object
 - #ns(xpath) ⇒ Object
 - 
  
    
      #parse(docxml)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
extract names for all anchors, xref and label.
 
Methods included from IsoDoc::XrefGen::Sections
#annex_name_lbl, #annex_names, #annex_names1, #back_anchor_names, #clause_names, #initial_anchor_names, #middle_section_asset_names, #preface_clause_name, #preface_names, #preface_names1, #reference_names, #section_names, #section_names1, #single_annex_special_section
Methods included from IsoDoc::XrefGen::Blocks
#amend_autonums, #amend_preprocess, #bookmark_anchor_names, #example_anchor_names, #hierarchical_asset_names, #hierarchical_figure_names, #hierarchical_formula_names, #hierarchical_permission_names, #hierarchical_permission_names1, #hierarchical_permission_names2, #hierarchical_table_names, #hierfigsep, #hiersep, #increment_label, #list_anchor_names, #list_item_anchor_names, #note_anchor_names, #sections_xpath, #sequential_asset_names, #sequential_figure_names, #sequential_formula_names, #sequential_permission_names, #sequential_permission_names1, #sequential_permission_names2, #sequential_table_names, #subfigure_increment, #termexample_anchor_names, #termnote_anchor_names, #termnote_label
Methods included from IsoDoc::XrefGen::Anchor
#anchor_struct, #anchor_struct_label, #anchor_struct_value, #anchor_struct_xref, #get_anchors
Constructor Details
#initialize(lang, script, klass, i18n, options = {}) ⇒ Xref
Returns a new instance of Xref.
      14 15 16 17 18 19 20 21 22 23  | 
    
      # File 'lib/isodoc/xref.rb', line 14 def initialize(lang, script, klass, i18n, = {}) @anchors = {} @lang = lang @script = script @klass = klass @options = @i18n = i18n @labels = @i18n.get @klass.i18n = @i18n end  | 
  
Instance Method Details
#anchor(id, lbl, warning = true) ⇒ Object
      29 30 31 32 33 34 35 36 37 38 39  | 
    
      # File 'lib/isodoc/xref.rb', line 29 def anchor(id, lbl, warning = true) return nil if id.nil? || id.empty? if warning && !@anchors[id] @seen ||= Seen_Anchor.instance @seen.seen(id) or warn "No label has been processed for ID #{id}" @seen.add(id) return "[#{id}]" end @anchors.dig(id, lbl) end  | 
  
#get ⇒ Object
      25 26 27  | 
    
      # File 'lib/isodoc/xref.rb', line 25 def get @anchors end  | 
  
#l10n(text, lang = @lang, script = @script) ⇒ Object
      58 59 60  | 
    
      # File 'lib/isodoc/xref.rb', line 58 def l10n(text, lang = @lang, script = @script) @i18n.l10n(text, lang, script) end  | 
  
#ns(xpath) ⇒ Object
      54 55 56  | 
    
      # File 'lib/isodoc/xref.rb', line 54 def ns(xpath) Common::ns(xpath) end  | 
  
#parse(docxml) ⇒ Object
extract names for all anchors, xref and label
      42 43 44 45 46 47 48 49 50 51 52  | 
    
      # File 'lib/isodoc/xref.rb', line 42 def parse(docxml) amend_preprocess(docxml) initial_anchor_names(docxml) back_anchor_names(docxml) # preempt clause notes with all other types of note (ISO default) note_anchor_names(docxml.xpath(ns("//table | //figure"))) note_anchor_names(docxml.xpath(ns(SECTIONS_XPATH))) example_anchor_names(docxml.xpath(ns(SECTIONS_XPATH))) list_anchor_names(docxml.xpath(ns(SECTIONS_XPATH))) bookmark_anchor_names(docxml) end  |