Using RowX records in a raw Dynarex document

Dynarex version 1.2 now supports the parsing of a raw Dynarex document which includes records in RowX format. The string pattern '--+' is used to declare the data below that line as RowX records.

All of the examples below return the same result:

example 1: simple

require 'dynarex'

s =<<EOF
<?dynarex schema="entries/entry(company,url,applied,type)"?>
--+
company: Oracle
url: foo 
applied: x123
type: YYY

company: Amazon
url: bar 
applied: y567
type: RRR
EOF

dynarex = Dynarex.new
dynarex.parse s  
puts dynarex.to_xml pretty: true

output:

<?xml v

<entries>
  <summary>
    <recordx_type>dynarex</recordx_type>
    <format_mask>[!company] [!url] [!applied] [!type]</format_mask>
    <schema>entries/entry(company,url,applied,type)</schema>
  </summary>
  <records>
    <entry id='1' created='2012-10-02 22:06:26 +0100' last_modified=''>
      <company>Oracle</company>
      <url>foo</url>
      <applied>x123</applied>
      <type>YYY</type>
    </entry>
    <entry id='2' created='2012-10-02 22:06:26 +0100' last_modified=''>
      <company>Amazon</company>
      <url>bar</url>
      <applied>y567</applied>
      <type>RRR</type>
    </entry>
  </records>
</entries>

example 2: with an

added summary

s =<<EOF
<?dynarex schema="entries[title,desc]/entry(company,url,applied,type)"?>
title: test 123
desc: testing the description

--+
company: Oracle
url: foo 
applied: x123
type: YYY

company: Amazon
url: bar 
applied: y567
type: RRR
EOF

dynarex = Dynarex.new
dynarex.parse s  
puts dynarex.to_xml pretty: true

output:

<?xml ve

<entries>
  <summary>
    <title>test 123</title>
    <desc>testing the description</desc>
    <recordx_type>dynarex</recordx_type>
    <schema>entries[title,desc]/entry(company,url,applied,type)</schema>
    <format_mask>[!company] [!url] [!applied] [!type]</format_mask>
  </summary>
  <records>
    <entry id='1' created='2012-10-02 22:11:46 +0100' last_modified=''>
      <company>Oracle</company>
      <url>foo</url>
      <applied>x123</applied>
      <type>YYY</type>
    </entry>
    <entry id='2' created='2012-10-02 22:11:46 +0100' last_modified=''>
      <company>Amazon</company>
      <url>bar</url>
      <applied>y567</applied>
      <type>RRR</type>
    </entry>
  </records>
</entries>

example 3: with line

comments and a record separator for clarity

s =<<EOF
<?dynarex schema="entries[title,desc]/entry(company,url,applied,type)"?>
title: test 123
desc: testing the description

# a comment can appear before the rowx data
--+

# or it can appear within the rowx data
company: Oracle
url: foo 
applied: x123
type: YYY
----------------------------
company: Amazon
url: bar 
applied: y567
type: RRR
EOF

dynarex = Dynarex.new
dynarex.parse s  
puts dynarex.to_xml pretty: true

output:

<?xml versi

<entries>
  <summary>
    <title>test 123</title>
    <desc>testing the description</desc>
    <recordx_type>dynarex</recordx_type>
    <schema>entries[title,desc]/entry(company,url,applied,type)</schema>
    <format_mask>[!company] [!url] [!applied] [!type]</format_mask>
  </summary>
  <records>
    <entry id='1' created='2012-10-02 22:17:34 +0100' last_modified=''>
      <company>Oracle</company>
      <url>foo</url>
      <applied>x123</applied>
      <type>YYY</type>
    </entry>
    <entry id='2' created='2012-10-02 22:17:34 +0100' last_modified=''>
      <company>Amazon</company>
      <url>bar</url>
      <applied>y567</applied>
      <type>RRR</type>
    </entry>
  </records>
</entries>

Tags:
Source:
2219hrs.txt
Published:
02-10-2012 22:19