Module: Duxml::RngValueRule
- Includes:
- LazyOx
- Included in:
- ValueRuleClass
- Defined in:
- lib/duxml/meta/grammar/relax_ng/value_rule.rb,
lib/duxml/meta/grammar/relax_ng/value_rule.rb
Instance Method Summary collapse
-
#relaxng(parent) ⇒ Nokogiri::XML::Node
Parent, but adds to corresponding <define><attribute> a child <data type=“#statement”> where #statement can be ‘CDATA’, ‘NMTOKEN’, etc.
Methods included from LazyOx
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Duxml::LazyOx
Instance Method Details
#relaxng(parent) ⇒ Nokogiri::XML::Node
Returns parent, but adds to corresponding <define><attribute> a child <data type=“#statement”> where #statement can be ‘CDATA’, ‘NMTOKEN’, etc.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/duxml/meta/grammar/relax_ng/value_rule.rb', line 17 def relaxng(parent) parent.Define.each do |define| if define[:name] == attr_name attr_def = define.nodes.first unless attr_def.nodes.any? data_type = statement == 'CDATA' ? 'string' : statement if data_type.include?('|') choice_node = Element.new('choice') attr_def << choice_node data_type.split(/[\(\|\)]/).each do |en_val| if !en_val.empty? && Regexp.nmtoken.match(en_val) value_def = Element.new('value') value_def << en_val choice_node << value_def end end else data_def = Element.new('data') data_def[:type] = data_type attr_def << data_def end end # unless attr_def.nodes.any? return parent end # if define[:name] == attr_name end # parent.nodes.each end |