Class: Nokogiri::XML::Schematron::Schema

Inherits:
Base
  • Object
show all
Defined in:
lib/nokogiri/xml/schematron/schema.rb

Overview

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

For example:

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

Instance Attribute Summary collapse

Attributes inherited from Base

#children, #options, #parent

Instance Method Summary collapse

Methods inherited from Base

attribute, element, #to_builder

Constructor Details

#initialize(**options) {|schema| ... } ⇒ Schema

Create a new Schema object.

Parameters:

  • options (Hash<Symbol, Object>)

    the options.

Options Hash (**options):

  • :id (#to_s)

    the value of the @id XML attribute.

  • :title (#to_s)

    the value of the @title XML element.

Yield Parameters:

Yield Returns:

  • (void)


63
64
65
# File 'lib/nokogiri/xml/schematron/schema.rb', line 63

def initialize(**options, &block)
  super(nil, **options, &block)
end

Instance Attribute Details

#idString

Returns the value of the @id XML attribute.

Returns:

  • (String)

    the value of the @id XML attribute.



21
# File 'lib/nokogiri/xml/schematron/schema.rb', line 21

attribute :id

#titleString

Returns the value of the @title XML element.

Returns:

  • (String)

    the value of the @title XML element.



25
# File 'lib/nokogiri/xml/schematron/schema.rb', line 25

attribute :title

Instance Method Details

#ns(**options) {|ns| ... } ⇒ Nokogiri::XML::Schematron::Namespace

Create a new Namespace object.

Parameters:

  • options (Hash<Symbol, Object>)

    the options.

Options Hash (**options):

  • :prefix (String)

    the value of the @prefix XML attribute.

  • :uri (String)

    the value of the @uri XML attribute.

Yield Parameters:

Yield Returns:

  • (void)

Returns:



35
# File 'lib/nokogiri/xml/schematron/schema.rb', line 35

element :ns, Nokogiri::XML::Schematron::Namespace

#p(**options) {|p| ... } ⇒ Nokogiri::XML::Schematron::Paragraph

Create a new Paragraph object.

Parameters:

  • options (Hash<Symbol, Object>)

    the options.

Options Hash (**options):

  • :message (String)

    the text content of the <sch:p> XML element.

Yield Parameters:

Yield Returns:

  • (void)

Returns:



44
# File 'lib/nokogiri/xml/schematron/schema.rb', line 44

element :p, Nokogiri::XML::Schematron::Paragraph

#pattern(**options) {|pattern| ... } ⇒ Nokogiri::XML::Schematron::Pattern

Create a new Pattern object.

Parameters:

  • options (Hash<Symbol, Object>)

    the options.

Options Hash (**options):

  • :id (String)

    the value of the @id XML attribute.

  • :title (String)

    the value of the @title XML element.

Yield Parameters:

Yield Returns:

  • (void)

Returns:



54
# File 'lib/nokogiri/xml/schematron/schema.rb', line 54

element :pattern, Nokogiri::XML::Schematron::Pattern