class Nokogiri::XML::Schematron::Pattern

The internal representation of the +<sch:pattern>+ XML element.

For example:

pattern = Nokogiri::XML::Schematron::Pattern.new(nil, id: "pattern1", title: "Example pattern")
# => #<Nokogiri::XML::Schematron::Pattern:0x00007f8486a71f18 @parent=nil, @children=[], @options={:id=>"pattern1", :title=>"Example pattern"}>
pattern.to_builder.to_xml
# => "<?xml version=\"1.0\"?>\n<sch:pattern xmlns:sch=\"http://purl.oclc.org/dsdl/schematron\" id=\"pattern1\">\n  <sch:title>Example pattern</sch:title>\n</sch:pattern>\n"

Protected Instance Methods

build!(xml) click to toggle source
Calls superclass method Nokogiri::XML::Schematron::Base#build!
# File lib/nokogiri/xml/schematron/pattern.rb, line 134
def build!(xml)
  xml["sch"].send(:pattern, %w(id).inject(xmlns) { |acc, method_name|
    unless (s = send(method_name.to_sym)).nil?
      acc[method_name.to_s] = s
    end

    acc
  }) do
    %w(title).each do |method_name|
      unless (s = send(method_name.to_sym)).nil?
        xml["sch"].send(method_name.to_sym, xmlns) do
          xml.text(s)
        end
      end
    end

    super(xml)
  end

  return
end