Polyrex-schema version 0.3

Polyrex-schema version 3.0 can now handle a schema that contain siblings recursively e.g.

require 'polyrex-schema'

o = PolyrexSchema.new 'a/{c[name,count];c2[age]/{f[title];f2[colour]}}/d[title]'
puts o.to_doc.xml pretty: true

output:

<?xml version='1.0' encoding='UTF-8'?>
<a>
  <summary>
    <recordx_type>polyrex</recordx_type>
    <schema>a/{c[name,count];c2[age]/{f[title];f2[colour]}}/d[title]</schema>
  </summary>
  <records>
    <c>
      <summary>
        <name></name>
        <count></count>
        <schema>c[name,count]/d[title]</schema>
        <format_mask>[!name] [!count]</format_mask>
      </summary>
      <records>
        <d>
          <summary>
            <title></title>
            <schema>d[title]</schema>
            <format_mask>[!title]</format_mask>
          </summary>
          <records></records>
        </d>
      </records>
    </c>
    <c2>
      <summary>
        <age></age>
        <schema>c2[age]/{f[title];f2[colour]}/d[title]</schema>
        <format_mask>[!age]</format_mask>
      </summary>
      <records>
        <f>
          <summary>
            <title></title>
            <schema>f[title]/d[title]</schema>
            <format_mask>[!title]</format_mask>
          </summary>
          <records>
            <d>
              <summary>
                <title></title>
                <schema>d[title]</schema>
                <format_mask>[!title]</format_mask>
              </summary>
              <records></records>
            </d>
          </records>
        </f>
        <f2>
          <summary>
            <colour></colour>
            <schema>f2[colour]/d[title]</schema>
            <format_mask>[!colour]</format_mask>
          </summary>
          <records>
            <d>
              <summary>
                <title></title>
                <schema>d[title]</schema>
                <format_mask>[!title]</format_mask>
              </summary>
              <records></records>
            </d>
          </records>
        </f2>
      </records>
    </c2>
  </records>
</a>

Resources

Tags:
Source:
1632hrs.txt
Published:
26-08-2014 16:32