<?xml version="1.0" encoding="UTF-8"?>
<!--
	File:    backoffice.xsd
	Author:  Chriztian Steinmeier
	Created: 2025-05-27
	Description:
		XMLSchema for a backoffice XML format.

-->
<xsd:schema
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://xmlns.greystate.dk/2025/backoffice"
	xmlns="http://xmlns.greystate.dk/2025/backoffice"
>

	<!-- Main description -->
	<xsd:annotation>
		<xsd:documentation xml:lang="en">
			<p xmlns="http://www.w3.org/1999/xhtml">
				An XML application for mocking up the structure of an Umbraco Backoffice.
			</p>
			<p xmlns="http://www.w3.org/1999/xhtml">
				Typical prefix is <var>doc</var> e.g. <code>&lt;doc:backoffice&gt;...&lt;/doc:backoffice&gt;</code>
			</p>
		</xsd:documentation>
	</xsd:annotation>

	<!-- Root element -->
	<xsd:element name="backoffice">
		<xsd:complexType>
			<xsd:choice minOccurs="0" maxOccurs="unbounded">
				<xsd:element ref="composition" />
				<xsd:element ref="doctype" />
			</xsd:choice>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="doctype">
		<xsd:complexType>
			<xsd:choice minOccurs="0" maxOccurs="unbounded">
				<xsd:element ref="composition" />
				<xsd:element ref="tab" />
				<xsd:element ref="group" />
			</xsd:choice>

			<xsd:attribute name="name" type="xsd:string" />
		</xsd:complexType>
	</xsd:element>

	<!-- SHOULD be able to do this: -->
	<!-- <xsd:element name="composition">
		<xsd:alternative type="compositionImport" test="@src" />
		<xsd:alternative type="compositionDefinition" test="*" />
	</xsd:element>

	<xsd:complexType name="compositionImport">
		<xsd:attribute name="src" type="xsd:anyURI" use="required" />
	</xsd:complexType>

	<xsd:complexType name="compositionDefinition">
		<xsd:choice>
			<xsd:element ref="tab" minOccurs="0" maxOccurs="unbounded" />
		</xsd:choice>

		<xsd:attribute name="name" type="xsd:string" use="optional" />
	</xsd:complexType> -->

	<xsd:element name="composition">
		<xsd:complexType>
			<xsd:choice minOccurs="0" maxOccurs="unbounded">
				<xsd:element ref="tab" />
			</xsd:choice>

			<xsd:attribute name="src" type="xsd:anyURI" use="optional" />
			<xsd:attribute name="name" type="xsd:string" use="optional" />
		</xsd:complexType>
	</xsd:element>

	<xsd:complexType name="compositionImport">
	</xsd:complexType>

	<xsd:complexType name="compositionDefinition">
	</xsd:complexType>

	<xsd:element name="tab">
		<xsd:complexType>
			<xsd:choice minOccurs="0" maxOccurs="unbounded">
				<xsd:element ref="group" />
			</xsd:choice>
			<xsd:attribute name="name" type="xsd:string" />
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="group">
		<xsd:complexType>
			<xsd:choice minOccurs="0" maxOccurs="unbounded">
				<xsd:element ref="text" />
				<xsd:element ref="picker" />
				<xsd:element ref="mediapicker" />
				<xsd:element ref="wysiwyg" />
			</xsd:choice>

			<xsd:attribute name="name" type="xsd:string" use="optional" />
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="desc" type="xsd:string" />

	<xsd:element name="text">
		<xsd:complexType>
			<xsd:choice minOccurs="0">
				<xsd:element ref="desc" minOccurs="0" maxOccurs="1" />
			</xsd:choice>

			<xsd:attribute name="label" type="xsd:string" use="required" />
			<xsd:attribute name="multiline" type="booleanYesNo" use="optional" />
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="picker">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element ref="caption" minOccurs="1" maxOccurs="1" />
			</xsd:sequence>

			<xsd:attribute name="label" type="xsd:string" use="required" />
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="mediapicker">
		<xsd:complexType>
			<xsd:attribute name="label" type="xsd:string" use="required" />
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="wysiwyg">
		<xsd:complexType>
			<xsd:attribute name="label" type="xsd:string" use="required" />
			<xsd:attribute name="variation" use="optional">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string">
						<xsd:enumeration value="simple" />
					</xsd:restriction>
				</xsd:simpleType>
			</xsd:attribute>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="caption" type="xsd:string" />

	<!-- Custom Types -->

	<xsd:simpleType name="booleanYesNo">
		<xsd:restriction base="xsd:string">
			<xsd:enumeration value="yes" />
			<xsd:enumeration value="no" />
		</xsd:restriction>
	</xsd:simpleType>


</xsd:schema>
