<?xml version="1.0"?>
<sx:resources xmlns:sx="http://www.servingxml.com/core">

  <sx:service id="students">
    <sx:serialize>
      <sx:transform>
        <sx:content ref="students-content"/>
      </sx:transform>
    </sx:serialize>
  </sx:service>

  <sx:recordContent id="students-content">
    <sx:flatFileReader>
      <sx:flatFile ref="students-file"/>
    </sx:flatFileReader>
    <sx:recordMapping ref="students-mapping"/>
  </sx:recordContent>

  <sx:flatFile id="students-file">
    <sx:flatFileBody>
      <sx:flatRecordType name="student">
        <sx:positionalField name="name" width="4"/>
        <sx:repeatingGroup name="grades">
          <sx:flatRecordType name="subject-grade">
            <sx:positionalField name="subject" width="4"/>
            <sx:positionalField name="grade" width="1"/>
          </sx:flatRecordType>
        </sx:repeatingGroup>
      </sx:flatRecordType>
    </sx:flatFileBody>
  </sx:flatFile>

  <sx:recordMapping id="students-mapping">
    <StudentGrades>
      <sx:onRecord>
        <StudentGrade>
          <sx:fieldElementMap field="name" element="Name"/>
          <sx:subrecordMapping repeatingGroup="grades">
            <sx:onRecord>
              <SubjectGrade>
                <sx:fieldElementMap field="subject" element="Subject"/>
                <sx:fieldElementMap field="grade" element="Grade"/>
              </SubjectGrade>
            </sx:onRecord>
          </sx:subrecordMapping>
        </StudentGrade>
      </sx:onRecord>
    </StudentGrades>
  </sx:recordMapping>

</sx:resources>

