<?xml version="1.0" encoding="UTF-8"?>
<!--
  Custom XML namespace for Aytict.fi documents
  Date: 2026-02-11

  Usage example:

    <aytictDoc
        xmlns="http://www.aytict.fi/xmlns"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.aytict.fi/xmlns aytict-xmlns.xml"
        id="doc-001"
        version="1.0">
      <meta title="Sample" author="aleksi" />
      <section id="intro" title="Introduction">
        <para>Welcome to Aytict.fi custom XML.</para>
      </section>
    </aytictDoc>

-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://www.aytict.fi/xmlns"
           xmlns="http://www.aytict.fi/xmlns"
           xmlns:tns="http://www.aytict.fi/xmlns"
           elementFormDefault="qualified">

  <!-- Basic simple types -->
  <xs:simpleType name="idType">
    <xs:restriction base="xs:string">
      <xs:pattern value="[A-Za-z_][A-Za-z0-9_\-\.]*"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="nonEmptyString">
    <xs:restriction base="xs:string">
      <xs:minLength value="1"/>
    </xs:restriction>
  </xs:simpleType>

  <!-- Global attributes -->
  <xs:attributeGroup name="commonAttrs">
    <xs:attribute name="id" type="tns:idType" use="optional"/>
    <xs:attribute name="class" type="tns:nonEmptyString" use="optional"/>
  </xs:attributeGroup>

  <!-- Root document element -->
  <xs:element name="aytictDoc">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="meta" type="tns:metaType" minOccurs="0" maxOccurs="1"/>
        <xs:element name="section" type="tns:sectionType" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attributeGroup ref="tns:commonAttrs"/>
      <xs:attribute name="version" type="tns:nonEmptyString" use="required"/>
      <xs:attribute name="created" type="xs:dateTime" use="optional"/>
      <xs:attribute name="updated" type="xs:dateTime" use="optional"/>
    </xs:complexType>
  </xs:element>

  <!-- Meta information about the document -->
  <xs:complexType name="metaType">
    <xs:attributeGroup ref="tns:commonAttrs"/>
    <xs:attribute name="title" type="tns:nonEmptyString" use="optional"/>
    <xs:attribute name="author" type="tns:nonEmptyString" use="optional"/>
    <xs:attribute name="description" type="tns:nonEmptyString" use="optional"/>
  </xs:complexType>

  <!-- Section with nested paragraphs or subsections -->
  <xs:complexType name="sectionType">
    <xs:sequence>
      <xs:element name="para" type="tns:paraType" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="section" type="tns:sectionType" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attributeGroup ref="tns:commonAttrs"/>
    <xs:attribute name="title" type="tns:nonEmptyString" use="optional"/>
  </xs:complexType>

  <!-- Paragraph content -->
  <xs:complexType name="paraType" mixed="true">
    <xs:attributeGroup ref="tns:commonAttrs"/>
  </xs:complexType>

</xs:schema>
