<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="properties" type="NFTProperties">
    <xs:key name="node-id-root">
      <xs:selector xpath="properties|property" />
      <xs:field xpath="@name" />
    </xs:key>
  </xs:element>
  <xs:complexType name="PropertyNode">
    <xs:attribute name="name" type="xs:string" use="required" />
  </xs:complexType>
  <xs:complexType name="Property">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="name" type="xs:string" use="required" />
        <xs:attribute name="type" type="proptype" use="optional" default="string"/>
        <xs:attribute name="readonly" type="xs:boolean" use="optional" default="false" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="NFTProperties">
    <xs:sequence>
      <xs:group ref="propertyNode" maxOccurs="unbounded" />
    </xs:sequence>
    <xs:attribute name="name" type="xs:string" use="required" />
  </xs:complexType>
  <xs:group name="propertyNode">
    <xs:sequence>
      <xs:element name="property" type="Property" minOccurs="0" maxOccurs="1" />
      <xs:element name="properties" type="NFTProperties" minOccurs="0" maxOccurs="1">
        <xs:key name="node-id">
          <xs:selector xpath="properties|property" />
          <xs:field xpath="@name" />
        </xs:key>
      </xs:element>
    </xs:sequence>
  </xs:group>
  <xs:simpleType name="proptype">
    <xs:restriction base="xs:string">
      <xs:enumeration value="string" />
      <xs:enumeration value="int" />
      <xs:enumeration value="bool" />
    </xs:restriction>
  </xs:simpleType>
</xs:schema>