<?xml version="1.0" encoding="UTF-8" ?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    elementFormDefault="qualified" attributeFormDefault="unqualified">

    <!-- Inclusion of other Building Blocks -->

    <!-- Same as elementName, elementNameRegerence redefined here to avoid inclusion of another XSD -->
    <xs:simpleType name="nodeElementName">
        <xs:restriction base="xs:string">
            <xs:pattern value="([a-zA-Z0-9_.])+" />
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="nodeElementNameReference">
        <xs:restriction base="xs:string">
            <xs:pattern value="((::)?[a-zA-Z0-9_.])+" />
        </xs:restriction>
    </xs:simpleType>

    <!-- Node Address definitions -->
    <xs:simpleType name="macAddress">
        <xs:restriction base="xs:string">
            <xs:pattern value="[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}" />
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="ipv4Address">
        <xs:restriction base="xs:string"/>
    </xs:simpleType>
    <xs:simpleType name="ipv6Address">
        <xs:restriction base="xs:string"/>
    </xs:simpleType>

    <!-- Node definitions -->
    <xs:complexType name="deploymentNode">
        <xs:choice minOccurs="1" maxOccurs="unbounded">
            <xs:element name="hostname" type="xs:string" />
            <xs:choice minOccurs="0" maxOccurs="1">
                <xs:element name="ipv4_address" type="ipv4Address"/>
                <xs:element name="ipv6_address" type="ipv6Address"/>
            </xs:choice>
            <xs:element name="mac_address" type="macAddress" />
        </xs:choice>
        <xs:attribute name="name" type="nodeElementName" use="required" />
    </xs:complexType>

    <!-- Node Library -->
    <xs:complexType name="nodeLibrary">
        <xs:choice minOccurs="1" maxOccurs="unbounded">
            <xs:element name="node" maxOccurs="unbounded" type="deploymentNode" />
        </xs:choice>
        <xs:attribute name="name" type="nodeElementName" use="required" />
    </xs:complexType>
</xs:schema>
