How To: Extend the Ed-Fi XML Schema (Part 2)

This section describes how to customize the Ed-Fi XSD using complex type extension.

Customizing by Using XML Complex Type Extension

XML supports the extension of complex types that can be used to add new elements. In this example, we will add the following elements:

  • A new element to ClassRanking to capture graduation information for special education students
  • A new element to StudentAcademicRecord to indicate if the transcript is an official or unofficial submission

To accomplish this, the following steps are taken:

  1. Use the base EXTENSION-Ed-Fi-Extended-Core.xsd, which includes the schema Ed-Fi-Core.xsd, to create the required extensions.
    • Note: The EXTENSION- prefix is a convention used in the Ed-Fi Extension Framework to denote custom type definitions.
  2. Define a descriptor named EXTENSION-SpecialEducationGraduationStatusDescriptor. We will provide the following values for the descriptor when implemented:
    • Completion of IEP and Reached Age 22
    • Completion of IEP and Access to Services, Employment, or Education
    • Completion of IEP and Demonstrated Self-Help Skills
  3. Define a descriptor named EXTENSION-SubmissionCertificationDescriptor. We will provide the following values for the descriptor when implemented:
    • Official
    • Unofficial
  4. Define an EXTENSION-StudentAcademicRecordRestriction to be a restriction with base of StudentAcademicRecord, as defined in Ed-Fi-Core.xsd.
  5. Within the restriction, define a sequence and restate the elements that exactly match those defined in StudentAcademicRecord and in the same order, with the exception of omitting the ClassRanking element.
  6. Define a new complex type EXTENSION-ClassRankingExtension.
  7. Define the EXTENSION-ClassRankingExtension to be an extension with a base of ClassRanking, as defined in Ed-Fi-Core.xsd.
  8. Within the EXTENSION-ClassRankingExtension type, add a sequence and define a new optional element for SpecialEducationGraduationStatus of type EXTENSION-SpecialEducationGraduationStatusDescriptorReferenceType.
  9. Define a new complex type EXTENSION-StudentAcademicRecordExtension.
  10. Define the EXTENSION-StudentAcademicRecordExtension to be an extension with a base of EXTENSION-StudentAcademicRecordRestriction (as defined in previous steps).
  11. Within the EXTENSION-StudentAcademicRecordExtension, add a sequence and define the following new elements:
    • For ClassRanking of type EXTENSION-ClassRankingExtension
    • For SubmissionCertification of type EXTENSION-SubmissionCertificationDescriptorReferenceType

The following is the resulting schema with annotations removed for brevity:

<?xml version="1.0" encoding="UTF-8"?>
<!-- (c)2017 Ed-Fi Alliance, LLC. All Rights Reserved. -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://ed-fi.org/0210" xmlns:ann="http://ed-fi.org/annotation" targetNamespace="http://ed-fi.org/0210" elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:include schemaLocation="Ed-Fi-Core.xsd"/>
  <xs:annotation>
    <xs:documentation>===== Ed-Fi 2.1 Extensions =====</xs:documentation>
  </xs:annotation>
  <xs:annotation>
    <xs:documentation>===== Domain Entities =====</xs:documentation>
  </xs:annotation>
  <xs:complexType name="EXTENSION-StudentAcademicRecordExtension">
    <xs:complexContent>
      <xs:extension base="EXTENSION-StudentAcademicRecordRestriction">
        <xs:sequence>
          <xs:element name="ClassRanking" type="EXTENSION-ClassRankingExtension" minOccurs="0"/>
          <xs:element name="SubmissionCertification" type="EXTENSION-SubmissionCertificationDescriptorReferenceType"/>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="EXTENSION-StudentAcademicRecordRestriction">
    <xs:complexContent>
      <xs:restriction base="StudentAcademicRecord">
        <xs:sequence>
          <xs:element name="CumulativeEarnedCredits" type="Credits" minOccurs="0"/>
          <xs:element name="CumulativeAttemptedCredits" type="Credits" minOccurs="0"/>
          <xs:element name="CumulativeGradePointsEarned" type="GPA" minOccurs="0"/>
          <xs:element name="CumulativeGradePointAverage" type="GPA" minOccurs="0"/>
          <xs:element name="GradeValueQualifier" type="GradeValueQualifier" minOccurs="0"/>
          <xs:element name="AcademicHonor" type="AcademicHonor" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="Recognition" type="Recognition" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="ProjectedGraduationDate" type="xs:date" minOccurs="0"/>
          <xs:element name="SessionEarnedCredits" type="Credits" minOccurs="0"/>
          <xs:element name="SessionAttemptedCredits" type="Credits" minOccurs="0"/>
          <xs:element name="SessionGradePointsEarned" type="GPA" minOccurs="0"/>
          <xs:element name="SessionGradePointAverage" type="GPA" minOccurs="0"/>
          <xs:element name="Diploma" type="Diploma" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="StudentReference" type="StudentReferenceType"/>
          <xs:element name="EducationOrganizationReference" type="EducationOrganizationReferenceType"/>
          <xs:element name="SchoolYear" type="SchoolYearType"/>
          <xs:element name="Term" type="TermDescriptorReferenceType"/>
          <xs:element name="ReportCardReference" type="ReportCardReferenceType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>
  <xs:annotation>
    <xs:documentation>===== Descriptors =====</xs:documentation>
  </xs:annotation>
  <xs:complexType name="EXTENSION-SpecialEducationGraduationStatusDescriptor">
    <xs:complexContent>
      <xs:extension base="DescriptorType"/>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="EXTENSION-SubmissionCertificationDescriptor">
    <xs:complexContent>
      <xs:extension base="DescriptorType"/>
    </xs:complexContent>
  </xs:complexType>
  <xs:annotation>
    <xs:documentation>===== Extended Descriptor Reference Types =====</xs:documentation>
  </xs:annotation>
  <xs:complexType name="EXTENSION-SpecialEducationGraduationStatusDescriptorReferenceType">
    <xs:complexContent>
      <xs:extension base="DescriptorReferenceType"/>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="EXTENSION-SubmissionCertificationDescriptorReferenceType">
    <xs:complexContent>
      <xs:extension base="DescriptorReferenceType"/>
    </xs:complexContent>
  </xs:complexType>
  <xs:annotation>
    <xs:documentation>===== Common Types =====</xs:documentation>
  </xs:annotation>
  <xs:complexType name="EXTENSION-ClassRankingExtension">
    <xs:complexContent>
      <xs:extension base="ClassRanking">
        <xs:sequence>
          <xs:element name="SpecialEducationGraduationStatus" type="EXTENSION-SpecialEducationGraduationStatusDescriptorReferenceType" minOccurs="0"/>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>

As seen in this example, deleting a reference to a common type with restriction and adding the extended common type back with extension may be combined to extend common types in specific entities.