<?xml version="1.0" encoding="UTF-8"?>
<!--
	File:    hyperlinks.xsd
	Author:  Chriztian Steinmeier
	Created: 2002-08-24
	Description:
		XMLSchema for the hyperlinks XML format.

	Revisions:
		2020-04-18: Updated to include the `<group>` element.
		2022-08-31: Updated to add an `order` attribute
-->
<xsd:schema
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://xmlns.greystate.dk/2020/hyperlinks"
	xmlns="http://xmlns.greystate.dk/2020/hyperlinks"
>

	<!-- Main description -->
	<xsd:annotation>
		<xsd:documentation xml:lang="en">
			<p xmlns="http://www.w3.org/1999/xhtml">
				An XML application for keeping track of great links to cool sites.
			</p>
			<p xmlns="http://www.w3.org/1999/xhtml">
				Typical prefix is <var>hyp</var> eg. <code>&lt;hyp:hyperlink&gt;...&lt;/hyp:hyperlink&gt;</code>
			</p>
		</xsd:documentation>
	</xsd:annotation>

	<!-- Root element -->
	<xsd:element name="hyperlinks">
		<xsd:complexType>
			<xsd:group ref="rootcontent" minOccurs="0" maxOccurs="unbounded" />
		</xsd:complexType>
	</xsd:element>

	<xsd:group name="rootcontent">
		<xsd:choice>
			<xsd:element ref="group" minOccurs="1" maxOccurs="1" />
			<xsd:element ref="category" minOccurs="1" maxOccurs="1" />
			<xsd:element ref="hyperlink" minOccurs="1" maxOccurs="1" />
		</xsd:choice>
	</xsd:group>

	<xsd:element name="group">
		<xsd:annotation>
			<xsd:documentation xml:lang="en">
				<p xmlns="http://www.w3.org/1999/xhtml">
					Used for segmenting categories at the root level.
				</p>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element ref="category" minOccurs="0" maxOccurs="unbounded" />
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="hyperlink">
		<xsd:annotation>
			<xsd:documentation xml:lang="en">
				<p xmlns="http://www.w3.org/1999/xhtml">
					Contains the data for a single hyperlink resource.
				</p>
			</xsd:documentation>
		</xsd:annotation>

		<xsd:complexType>
			<xsd:sequence>
				<xsd:element ref="name" minOccurs="1" maxOccurs="1" />
				<xsd:element ref="url" minOccurs="1" maxOccurs="1" />
				<xsd:element ref="description" minOccurs="0" maxOccurs="1" />
			</xsd:sequence>

			<xsd:attribute name="new" use="optional">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string">
						<xsd:enumeration value="yes" />
						<xsd:enumeration value="no" />
					</xsd:restriction>
				</xsd:simpleType>
			</xsd:attribute>
			<xsd:attribute name="owner" type="xsd:string" use="optional" />
			<xsd:attribute name="order" type="xsd:integer" use="optional" />
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="category">
		<xsd:annotation>
			<xsd:documentation xml:lang="en">
				<p xmlns="http://www.w3.org/1999/xhtml">
					Used for grouping several hyperlinks under the same heading.
				</p>
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element ref="hyperlink" minOccurs="0" maxOccurs="unbounded" />
			</xsd:sequence>

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

	<xsd:element name="name" type="xsd:string" />
	<xsd:element name="url" type="xsd:anyURI" />
	<xsd:element name="description" type="xsd:string" />

</xsd:schema>
