<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="https://schemas.rutdev.se/xsd/entities/level2/represented-variable-1.0.xsd"
    xmlns:strings="https://schemas.rutdev.se/xsd/types/strings-1.0.xsd"
    targetNamespace="https://schemas.rutdev.se/xsd/entities/level2/represented-variable-1.0.xsd"
    elementFormDefault="qualified"
    version="1.0">

    <!--
      RepresentedVariable Schema

      Description: RepresentedVariable is a conceptual variable with an associated value domain that specifies how the concept is represented or measured. It defines both the meaning (through the conceptual variable) an...
      Version: 1.0
      Generated: 2026-04-22T06:56:44Z
      Source: specs/entities/level2/represented-variable-1.0.md
    -->

    <!-- Import common type definitions -->
    <xsd:import
        namespace="https://schemas.rutdev.se/xsd/types/strings-1.0.xsd"
        schemaLocation="../../../types/strings-1.0.xsd"
    />

    <!-- Properties type: all data fields from entity specification -->
    <xsd:complexType name="RepresentedVariablePropertiesType">
        <xsd:sequence>
            <xsd:element name="IdAtOrigin" type="strings:IdentifierToken">
                <xsd:annotation>
                    <xsd:documentation>
                        Identifier at the source system for the represented-variable. Used during import to determine if the entity already exists in the target system (update) or is new (create). Must remain stable in the source system for the same entity.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="Name" type="strings:MultilingualShortString" minOccurs="0" maxOccurs="unbounded">
                <xsd:annotation>
                    <xsd:documentation>
                        The name of the represented variable
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="Description" type="strings:MultilingualLongString" minOccurs="0" maxOccurs="unbounded">
                <xsd:annotation>
                    <xsd:documentation>
                        Detailed description of how the variable is represented
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="Definition" type="strings:MultilingualLongString" minOccurs="0" maxOccurs="unbounded">
                <xsd:annotation>
                    <xsd:documentation>
                        The formal definition of the variable, capturing the meaning of what is measured. Corresponds to the GSIM Concept.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>

    <!-- Relations type: all relationships use EntityReference -->
    <xsd:complexType name="RepresentedVariableRelationsType">
        <xsd:sequence>
            <xsd:element name="hasValueDomain" type="strings:EntityReference" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Reference to EnumeratedValueDomain (has value domain)
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="representsConcept" type="strings:EntityReference" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Reference to ConceptualVariable (represents concept)
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>

    <!-- Main entity type -->
    <xsd:complexType name="RepresentedVariableType">
        <xsd:sequence>
            <xsd:element name="properties" type="tns:RepresentedVariablePropertiesType" minOccurs="0"/>
            <xsd:element name="relations" type="tns:RepresentedVariableRelationsType" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>

    <!-- Collection type -->
    <xsd:complexType name="RepresentedVariableListType">
        <xsd:sequence>
            <xsd:element name="representedVariable" type="tns:RepresentedVariableType" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>

    <!-- Root elements -->
    <xsd:element name="RepresentedVariable" type="tns:RepresentedVariableType"/>
    <xsd:element name="RepresentedVariableList" type="tns:RepresentedVariableListType"/>

</xsd:schema>