Class: Uniword::Validation::Rules::McIgnorableNamespaceRule
- Defined in:
- lib/uniword/validation/rules/mc_ignorable_namespace_rule.rb
Overview
Validates that mc:Ignorable namespace prefixes have xmlns declarations.
DOC-100: mc:Ignorable lists prefixes that must have xmlns in scope Validity rule: R1
Constant Summary collapse
- MC_NS =
"http://schemas.openxmlformats.org/markup-compatibility/2006"- PARTS =
[ "word/document.xml", "word/styles.xml", "word/settings.xml", "word/numbering.xml", "word/fontTable.xml", "word/webSettings.xml", ].freeze
Instance Method Summary collapse
- #applicable?(context) ⇒ Boolean
- #category ⇒ Object
- #check(context) ⇒ Object
- #code ⇒ Object
- #description ⇒ Object
- #severity ⇒ Object
- #validity_rule ⇒ Object
Instance Method Details
#applicable?(context) ⇒ Boolean
30 31 32 |
# File 'lib/uniword/validation/rules/mc_ignorable_namespace_rule.rb', line 30 def applicable?(context) PARTS.any? { |p| context.part_exists?(p) } end |
#category ⇒ Object
18 |
# File 'lib/uniword/validation/rules/mc_ignorable_namespace_rule.rb', line 18 def category = :namespaces |
#check(context) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/uniword/validation/rules/mc_ignorable_namespace_rule.rb', line 34 def check(context) issues = [] PARTS.each do |part_name| next unless context.part_exists?(part_name) doc = context.part(part_name) next unless doc root = doc.root next unless root ignorable_attr = root.attribute("Ignorable") || root.attributes.find { |a| a.name == "Ignorable" } next unless ignorable_attr && !ignorable_attr.value.strip.empty? prefixes = ignorable_attr.value.strip.split(/\s+/) check_prefixes(root, prefixes, part_name, issues) end issues end |
#code ⇒ Object
15 |
# File 'lib/uniword/validation/rules/mc_ignorable_namespace_rule.rb', line 15 def code = "DOC-100" |
#description ⇒ Object
17 |
# File 'lib/uniword/validation/rules/mc_ignorable_namespace_rule.rb', line 17 def description = "mc:Ignorable prefixes must have xmlns declarations in scope" |
#severity ⇒ Object
19 |
# File 'lib/uniword/validation/rules/mc_ignorable_namespace_rule.rb', line 19 def severity = "error" |
#validity_rule ⇒ Object
16 |
# File 'lib/uniword/validation/rules/mc_ignorable_namespace_rule.rb', line 16 def validity_rule = "R1" |