What is an Abstract Element and how can I use it?

Abstract elements are elements defined in XML schema but cannot appear in an XML instance; this is an XML schema mechanism for forcing substitution. Substitution groups must be used whenever abstract elements are defined; an element that is a member of the abstract element’s substitution group must appear in place of the abstract element in an XML instance.


NIEM uses abstract elements as the head-element for all substitution groups.  Abstract elements are used throughout the NIEM wherever there is a concept that can be represented multiple ways.  An abstract element serves as a placeholder in the reference model, but it must be substituted when creating an exchange specification. 


Below is a snippet of NIEM schema to illustrate this.


<xsd:complexType name="PersonType">


                                <xsd:extension base="u:SuperType">


                                                                <xsd:element ref="u:PersonSex" minOccurs="0" maxOccurs="unbounded"/>   






<xsd:element name="PersonSex" abstract="true"/>

<xsd:element name="PersonSexText" type="u:TextType" substitutionGroup="u:PersonSex" / >

<xsd:element name="PersonSexCode" type="ncic:SEXCodeType" substitutionGroup="u:PersonSex" / >



In the example above both PersonSexText and PersonSexCode belong to the PersonSex substitution group.  This means either PersonSexText or PersonSexCode must replace PersonSex whenever PersonType is instantiated.