Class: Rng::RncBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/rng/rnc_parser.rb

Instance Method Summary collapse

Instance Method Details

#build(schema) ⇒ Object



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/rng/rnc_parser.rb', line 220

def build(schema)
  if schema.element
    # Simple element pattern
    build_element(schema.element)
  else
    # Grammar with named patterns
    result = []

    # Add datatype library if present
    if schema.datatypeLibrary
      result << "datatypes xsd = \"#{schema.datatypeLibrary}\""
      result << ""
    end

    # Process start pattern
    if schema.start
      result << "start = #{build_pattern(schema.start)}"
      result << ""
    end

    # Process named patterns
    if schema.define && !schema.define.empty?
      schema.define.each do |define|
        result << "#{define.name} = #{build_pattern(define)}"
        result << ""
      end
    end

    result.join("\n")
  end
end