<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://apache.org/xsp" xmlns:xsp="http://apache.org/xsp" xmlns:sdx="http://www.culture.gouv.fr/ns/sdx/sdx" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
    <xsd:import namespace="http://www.culture.gouv.fr/ns/sdx/sdx" schemaLocation="api-sdx.xsd"/>
    <xsd:group name="external">
        <xsd:choice>
            <xsd:any namespace="http://www.culture.gouv.fr/ns/sdx/sdx"  processContents="strict"/>
            <xsd:any namespace="##other"/>
            <!-- careful with any for precise validation,
             better is to precise your own namespaces
            -->
            <xsd:any/>
        </xsd:choice>
    </xsd:group>
    <!-- root element -->
    <xsd:element name="page">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="xsp:structure" minOccurs="0" maxOccurs="1"/>
                <xsd:element ref="xsp:logicsheet" minOccurs="0" maxOccurs="unbounded"/>
                <xsd:element ref="xsp:logic" minOccurs="0" maxOccurs="unbounded"/>
                <!-- HERE YOUR ROOT OUTPUT ELEMENT -->
                <xsd:choice>
                    <xsd:group ref="xsp:inline"/>
                    <xsd:group ref="xsp:block"/>
                    <xsd:group ref="xsp:external"/>
                </xsd:choice>
            </xsd:sequence>
            <xsd:attribute name="language" type="xsd:string" default="java"/>
            <xsd:attribute name="result-ns" type="xsd:NMTOKEN"/>
            <xsd:attribute name="default-space" default="preserve" type="xsp:strip-space"/>
            <xsd:attribute name="indent-result" default="no" type="xsp:bool"/>
            <xsd:attribute ref="xml:space"/>
        </xsd:complexType>
    </xsd:element>
    <!-- "xsp:head" ; declare elements -->
    <xsd:element name="include" type="xsd:string"/>
    <xsd:element name="structure">
        <xsd:complexType>
            <xsd:sequence minOccurs="0" maxOccurs="unbounded">
                <xsd:element ref="xsp:include"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="logicsheet">
        <xsd:complexType>
            <xsd:attribute name="location" use="required"/>
        </xsd:complexType>
    </xsd:element>
    <!-- group "xsp:inline" ; controled content elements -->
    <xsd:group name="inline">
        <xsd:choice>
            <xsd:element ref="xsp:expr"/>
            <xsd:element ref="xsp:element"/>
            <xsd:element ref="xsp:attribute"/>
            <xsd:element ref="xsp:pi"/>
            <xsd:element ref="xsp:comment"/>
        </xsd:choice>
    </xsd:group>
    <!-- dynamic resutls content of a java variable -->
    <xsd:element name="expr" type="xsd:string"/>
    <!-- il n'est pas encore possible de générer dynamiquement des balises -->
    <xsd:element name="element"/>
    <!-- generated XML elements -->
    <xsd:element name="attribute">
        <xsd:complexType mixed="true">
            <xsd:sequence>
                <xsd:element ref="xsp:expr" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
            <xsd:attribute name="name" use="required"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="comment">
        <xsd:complexType mixed="true">
            <xsd:choice minOccurs="0" maxOccurs="unbounded">
                <xsd:element ref="xsp:expr"/>
            </xsd:choice>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="pi">
        <xsd:complexType mixed="true">
            <xsd:choice minOccurs="0" maxOccurs="unbounded">
                <xsd:element ref="xsp:expr"/>
            </xsd:choice>
        </xsd:complexType>
    </xsd:element>
    <!-- group "xsp:block" -->
    <xsd:group name="block">
        <xsd:choice>
            <xsd:element ref="xsp:logic"/>
            <xsd:element ref="xsp:content"/>
        </xsd:choice>
    </xsd:group>
    <xsd:element name="content">
        <xsd:complexType mixed="true">
            <xsd:choice minOccurs="0" maxOccurs="unbounded">
                <xsd:element ref="xsp:logic"/>
                <xsd:group ref="xsp:inline"/>
                <xsd:group ref="xsp:external"/>
            </xsd:choice>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="logic">
        <xsd:complexType mixed="true">
            <xsd:choice minOccurs="0" maxOccurs="unbounded">
                <xsd:group ref="xsp:external"/>
                <xsd:element ref="xsp:content"/>
                <xsd:group ref="xsp:inline"/>
            </xsd:choice>
            <xsd:attribute ref="xml:space"/>
        </xsd:complexType>
    </xsd:element>
    <!-- types -->
    <xsd:simpleType name="strip-space">
        <xsd:restriction base="xsd:NMTOKEN">
            <xsd:enumeration value="preserve"/>
            <xsd:enumeration value="strip"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="bool">
        <xsd:restriction base="xsd:NMTOKEN">
            <xsd:enumeration value="yes"/>
            <xsd:enumeration value="no"/>
        </xsd:restriction>
    </xsd:simpleType>
</xsd:schema>
