<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ld="urn:label-panel-data:1" targetNamespace="urn:label-panel-data:1" elementFormDefault="qualified">
  <xs:annotation><xs:documentation>Label display-data exchange version 1.0.0. This application schema is not FDA SPL. Amounts and percentages are declared display strings, including units, symbols and qualifiers; they are not raw assay measurements. A receiving ERP/PIM must map this schema to its own import contract.</xs:documentation></xs:annotation>
  <xs:simpleType name="NonEmpty"><xs:restriction base="xs:string"><xs:minLength value="1"/></xs:restriction></xs:simpleType>
  <xs:simpleType name="PanelKind"><xs:restriction base="xs:string"><xs:enumeration value="supplement_facts"/><xs:enumeration value="nutrition_facts"/></xs:restriction></xs:simpleType>
  <xs:element name="LabelData">
    <xs:complexType><xs:sequence>
      <xs:element name="Purpose" type="xs:string"/>
      <xs:element name="Identifiers"><xs:complexType><xs:sequence><xs:element name="ProductId" type="ld:NonEmpty"/><xs:element name="LabelProjectId" type="ld:NonEmpty" minOccurs="0"/></xs:sequence></xs:complexType></xs:element>
      <xs:element name="Layout"><xs:complexType><xs:attribute name="format" type="ld:NonEmpty" use="required"/><xs:attribute name="mode" type="xs:string"/></xs:complexType></xs:element>
      <xs:element name="Serving"><xs:complexType><xs:sequence>
        <xs:element name="ServingSizeDisplay" type="xs:string"/><xs:element name="ServingsPerContainerDisplay" type="xs:string"/>
        <xs:element name="Populations"><xs:complexType><xs:sequence><xs:element name="Population" minOccurs="0" maxOccurs="unbounded"><xs:complexType><xs:sequence><xs:element name="ServingSizeDisplay" type="xs:string" minOccurs="0"/></xs:sequence><xs:attribute name="key" type="ld:NonEmpty" use="required"/></xs:complexType></xs:element></xs:sequence></xs:complexType></xs:element>
      </xs:sequence></xs:complexType></xs:element>
      <xs:element name="Sections"><xs:complexType><xs:sequence><xs:element name="Section" minOccurs="0" maxOccurs="unbounded"><xs:complexType><xs:sequence><xs:element name="Title" type="xs:string"/></xs:sequence><xs:attribute name="id" type="ld:NonEmpty" use="required"/></xs:complexType></xs:element></xs:sequence></xs:complexType></xs:element>
      <xs:element name="Rows"><xs:complexType><xs:sequence><xs:element name="Row" minOccurs="0" maxOccurs="unbounded"><xs:complexType><xs:sequence>
        <xs:element name="Label" type="xs:string"/><xs:element name="Notes" minOccurs="0"><xs:complexType><xs:sequence><xs:element name="Note" type="xs:string" minOccurs="1" maxOccurs="unbounded"/></xs:sequence></xs:complexType></xs:element>
        <xs:element name="Cells"><xs:complexType><xs:sequence><xs:element name="Cell" minOccurs="0" maxOccurs="unbounded"><xs:complexType><xs:sequence><xs:element name="Display" type="xs:string" nillable="true"/></xs:sequence><xs:attribute name="key" type="ld:NonEmpty" use="required"/><xs:attribute name="header" type="xs:string" use="required"/><xs:attribute name="kind" use="required"><xs:simpleType><xs:restriction base="xs:string"><xs:enumeration value="amount"/><xs:enumeration value="dv"/></xs:restriction></xs:simpleType></xs:attribute></xs:complexType></xs:element></xs:sequence></xs:complexType></xs:element>
      </xs:sequence><xs:attribute name="id" type="ld:NonEmpty" use="required"/><xs:attribute name="indent" type="xs:nonNegativeInteger" use="required"/><xs:attribute name="sectionId" type="ld:NonEmpty"/><xs:attribute name="role" type="xs:string"/></xs:complexType><xs:unique name="CellKeys"><xs:selector xpath="ld:Cells/ld:Cell"/><xs:field xpath="@key"/></xs:unique></xs:element></xs:sequence></xs:complexType></xs:element>
      <xs:element name="Footnotes"><xs:complexType><xs:sequence><xs:element name="Footnote" minOccurs="0" maxOccurs="unbounded"><xs:complexType><xs:sequence><xs:element name="Text" type="xs:string"/><xs:element name="RowRef" type="xs:string" minOccurs="0" maxOccurs="unbounded"/></xs:sequence><xs:attribute name="symbol" type="xs:string" use="required"/></xs:complexType></xs:element></xs:sequence></xs:complexType></xs:element>
      <xs:element name="Statements"><xs:complexType><xs:sequence><xs:element name="Ingredients" type="xs:string" minOccurs="0"/><xs:element name="OtherIngredients" type="xs:string" minOccurs="0"/><xs:element name="AllergenStatement" type="xs:string" minOccurs="0" nillable="true"/><xs:element name="NotSignificantSource" type="xs:string" minOccurs="0"/></xs:sequence></xs:complexType></xs:element>
    </xs:sequence><xs:attribute name="schemaVersion" type="xs:string" use="required" fixed="1.0.0"/><xs:attribute name="panelKind" type="ld:PanelKind" use="required"/><xs:attribute name="generatedAt" type="xs:dateTime" use="required"/><xs:attribute name="submissionReady" type="xs:boolean" use="required" fixed="false"/></xs:complexType>
    <xs:key name="SectionIds"><xs:selector xpath="ld:Sections/ld:Section"/><xs:field xpath="@id"/></xs:key>
    <xs:key name="RowIds"><xs:selector xpath="ld:Rows/ld:Row"/><xs:field xpath="@id"/></xs:key>
    <xs:keyref name="RowSection" refer="ld:SectionIds"><xs:selector xpath="ld:Rows/ld:Row"/><xs:field xpath="@sectionId"/></xs:keyref>
  </xs:element>
</xs:schema>
