<?xml version="1.0"?>
<!--

  This file is part of the Meeds project (https://meeds.io/).

  Copyright (C) 2020 - 2025 Meeds Association contact@meeds.io

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 3 of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License
  along with this program; if not, write to the Free Software Foundation,
  Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

-->
<xs:schema
  targetNamespace="http://www.exoplatform.org/xml/ns/gatein_objects_1_14"
  xmlns="http://www.exoplatform.org/xml/ns/gatein_objects_1_14"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  elementFormDefault="qualified"
  attributeFormDefault="unqualified"
  version="1.0">

    <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>

    <!-- A top page element -->
    <xs:element name="page" type="pageType"/>
    <xs:element name="page-template" type="pageTemplateType"/>

    <!-- A top page-set element -->
    <xs:element name="page-set" type="pageSetType"/>

    <!-- A top portal-config element -->
    <xs:element name="portal-config" type="portalConfigType"/>

    <!-- A top container element -->
    <xs:element name="container" type="containerType"/>
    <xs:element name="section-banner" type="sectionBannerType"/>
    <xs:element name="section-sidebar" type="sectionSidebarType"/>
    <xs:element name="section-grid" type="sectionGridType"/>
    <xs:element name="section-columns" type="sectionColumnsType"/>
    <xs:element name="cell" type="cellType"/>
    <xs:element name="banner-cell" type="bannerCellType"/>
    <xs:element name="sidebar-cell" type="sidebarCellType"/>
    <xs:element name="column" type="columnType"/>
    <xs:element name="css-style" type="styleType"/>

    <!-- A top node-navigation element -->
    <xs:element name="node-navigation" type="nodeNavigationType"/>

    <!-- A localized string -->
    <xs:complexType name="localizedString">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute ref="xml:lang"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <!-- The type of a top navigation node -->
    <xs:complexType name="nodeNavigationType">
        <xs:sequence>
            <xs:element name="priority" type="xs:positiveInteger" minOccurs="0" maxOccurs="1"/>
            <xs:element name="page-nodes" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="parent-uri" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
                        <xs:element name="node" type="nodeType" minOccurs="0" maxOccurs="unbounded"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

    <!-- The type of a navigation node -->
    <xs:complexType name="nodeType">
        <xs:sequence>
            <xs:element name="name" type="xs:string"/>
            <xs:element name="label" type="localizedString" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element name="icon" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="start-publication-date" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="end-publication-date" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="visibility" type="visibility" default="DISPLAYED" minOccurs="0" maxOccurs="1"/>
            <xs:element name="page-reference" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="insertion-index" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="node" type="nodeType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:simpleType name="visibility">
        <xs:restriction base='xs:string'>
            <xs:enumeration value="DISPLAYED"/>
            <xs:enumeration value="HIDDEN"/>
            <xs:enumeration value="TEMPORAL"/>
            <xs:enumeration value="SYSTEM"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="pageSetType">
        <xs:sequence>
            <xs:element name="page" type="pageType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="portalConfigType">
        <xs:sequence>
            <xs:element name="portal-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="label" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="displayed" type="xs:boolean" default="true" minOccurs="0" maxOccurs="1"/>
            <xs:element name="display-order" type="xs:positiveInteger" minOccurs="0" maxOccurs="1"/>
            <xs:element name="locale" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="access-permissions" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="edit-permission" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="skin" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="properties" type="propertiesType" minOccurs="0" maxOccurs="1"/>
            <xs:element name="portal-layout" minOccurs="1" maxOccurs="1">
                <xs:complexType>
                    <xs:group ref="containerChildrenGroup"/>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="propertiesType">
        <xs:sequence minOccurs="0" maxOccurs="unbounded">
            <xs:element name="entry" type="propertiesEntryType" minOccurs="1" maxOccurs="1"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="propertiesEntryType">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="key" type="xs:string"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <xs:group name="containerChildrenGroup">
        <xs:sequence>
            <xs:element name="move-apps-permissions" type="xs:string" minOccurs="0" maxOccurs="1" default="Everyone"/>
            <xs:element name="move-containers-permissions" type="xs:string" minOccurs="0" maxOccurs="1" default="Everyone"/>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element name="portlet-application" type="portletApplicationType" minOccurs="1" maxOccurs="1"/>
                <xs:element name="section-grid" type="sectionGridType" minOccurs="1" maxOccurs="1" />
                <xs:element name="section-columns" type="sectionColumnsType" minOccurs="1" maxOccurs="1" />
                <xs:element name="section-sidebar" type="sectionSidebarType" />
                <xs:element name="site-middle-section" type="siteMiddleSectionType" />
                <xs:element name="container" type="containerType" minOccurs="1" maxOccurs="1"/>
                <xs:element name="page-body" type="xs:string" minOccurs="1" maxOccurs="1"/>
                <xs:element name="site-body" type="xs:string" minOccurs="1" maxOccurs="1"/>
            </xs:choice>
        </xs:sequence>
    </xs:group>

    <xs:group name="siteMiddleCenterSectionGroup">
      <xs:sequence>
        <xs:choice
          minOccurs="1"
          maxOccurs="unbounded">
          <xs:element
            name="section-sidebar"
            type="sectionSidebarType"
            minOccurs="0"
            maxOccurs="2" />
          <xs:element
            name="page-body"
            type="xs:string"
            minOccurs="1"
            maxOccurs="1" />
        </xs:choice>
      </xs:sequence>
    </xs:group>

    <xs:group name="siteMiddleSectionGroup">
      <xs:sequence>
        <xs:choice
          minOccurs="1"
          maxOccurs="unbounded">
          <xs:element
            name="section-banner"
            type="sectionBannerType"
            minOccurs="0"
            maxOccurs="unbounded" />
          <xs:element
            name="site-middle-center-section"
            type="siteMiddleCenterSectionType"
            minOccurs="1"
            maxOccurs="1" />
        </xs:choice>
      </xs:sequence>
    </xs:group>

    <xs:complexType name="siteMiddleSectionType">
      <xs:group ref="siteMiddleSectionGroup"/>
      <xs:attribute name="id" type="xs:string" />
      <xs:attribute name="cssClass" type="xs:string"/>
      <xs:element name="css-style" type="styleType" minOccurs="0" maxOccurs="1" />
    </xs:complexType>

    <xs:complexType name="siteMiddleCenterSectionType">
      <xs:group ref="siteMiddleCenterSectionGroup"/>
      <xs:attribute name="id" type="xs:string" />
      <xs:attribute name="cssClass" type="xs:string"/>
      <xs:element name="css-style" type="styleType" minOccurs="0" maxOccurs="1" />
    </xs:complexType>

    <xs:complexType name="sectionSidebarType">
      <xs:sequence>
        <xs:element name="access-permissions" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="css-style" type="styleType" minOccurs="0" maxOccurs="1" />
        <xs:element name="sidebar-cell" type="sidebarCellType" minOccurs="1" maxOccurs="1" />
      </xs:sequence>
      <xs:attribute name="id" type="xs:string" />
      <xs:attribute name="width" type="xs:string"/>
      <xs:attribute name="cssClass" type="xs:string"/>
      <xs:attribute name="sticky-beahvior" type="xs:boolean" />
      <xs:attribute name="profiles" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="sidebarCellType">
      <xs:sequence>
        <xs:element name="access-permissions" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="css-style" type="styleType" minOccurs="0" maxOccurs="1" />
        <xs:element name="portlet-application" type="portletApplicationType" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attribute name="id" type="xs:string" />
      <xs:attribute name="width" type="xs:string"/>
      <xs:attribute name="cssClass" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="sectionBannerType">
      <xs:sequence>
        <xs:element name="access-permissions" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="css-style" type="styleType" minOccurs="0" maxOccurs="1" />
        <xs:element name="banner-cell" type="bannerCellType" minOccurs="1" maxOccurs="1" />
      </xs:sequence>
      <xs:attribute name="id" type="xs:string" />
      <xs:attribute name="height" type="xs:string"/>
      <xs:attribute name="cssClass" type="xs:string"/>
      <xs:attribute name="sticky-beahvior" type="xs:boolean" />
      <xs:attribute name="profiles" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="bannerCellType">
      <xs:sequence>
        <xs:element name="access-permissions" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="css-style" type="styleType" minOccurs="0" maxOccurs="1" />
        <xs:element name="portlet-application" type="portletApplicationType" minOccurs="0" maxOccurs="1" />
      </xs:sequence>
      <xs:attribute name="id" type="xs:string" />
      <xs:attribute name="h-align" type="xs:string"/>
      <xs:attribute name="v-align" type="xs:string"/>
      <xs:attribute name="width" type="xs:string"/>
      <xs:attribute name="cssClass" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="pageType">
        <xs:sequence>
            <xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="title" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="factory-id" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="access-permissions" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="edit-permission" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="show-max-window" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
            <xs:element name="hide-shared-layout" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
            <xs:group ref="containerChildrenGroup"/>
        </xs:sequence>
        <xs:attribute name="profiles" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="pageTemplateType">
      <xs:group ref="containerChildrenGroup"/>
    </xs:complexType>

    <xs:complexType name="containerType">
        <xs:sequence>
            <xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="title" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="icon" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="access-permissions" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="factory-id" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:group ref="containerChildrenGroup"/>
        </xs:sequence>
        <xs:attribute name="id" type="xs:string"/>
        <xs:attribute name="template" type="xs:string"/>
        <xs:attribute name="attribute" type="xs:string"/>
        <xs:attribute name="width" type="xs:string"/>
        <xs:attribute name="height" type="xs:string"/>
        <xs:attribute name="cssClass" type="xs:string"/>
        <xs:attribute name="profiles" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="portletApplicationType">
        <xs:sequence>
            <xs:element name="portlet" type="portletType"/>
            <xs:group ref="applicationGroup"/>
        </xs:sequence>
    </xs:complexType>

    <xs:group name="applicationGroup">
        <xs:sequence>
            <xs:element name="theme" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="title" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="access-permissions" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="show-info-bar" type="xs:boolean" minOccurs="1" maxOccurs="1"/>
            <xs:element name="show-application-state" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
            <xs:element name="show-application-mode" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
            <xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="icon" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="width" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="height" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="cssClass" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="css-style" type="styleType" minOccurs="0" maxOccurs="1" />
        </xs:sequence>
    </xs:group>

    <xs:complexType name="portletType">
      <xs:sequence>
        <xs:element name="application-ref" type="xs:string" minOccurs="1" maxOccurs="1"/>
        <xs:element name="portlet-ref" type="xs:string" minOccurs="1" maxOccurs="1"/>
        <xs:element name="preferences" type="portletPreferencesType" minOccurs="0" maxOccurs="1"/>
      </xs:sequence>
      <xs:attribute name="profiles" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="sectionGridType">
      <xs:sequence>
        <xs:element name="access-permissions" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="css-style" type="styleType" minOccurs="0" maxOccurs="1"/>
        <xs:element name="cell" type="cellType" minOccurs="1" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attribute name="id" type="xs:string" />
      <xs:attribute name="cols">
        <xs:simpleType>
          <xs:restriction base="xs:integer">
            <xs:minInclusive value="1"/>
            <xs:maxInclusive value="12"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="rows">
        <xs:simpleType>
          <xs:restriction base="xs:integer">
            <xs:minInclusive value="1"/>
            <xs:maxInclusive value="12"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="cssClass" type="xs:string"/>
      <xs:attribute name="profiles" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="sectionFlexType">
      <xs:sequence>
        <xs:element name="access-permissions" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="css-style" type="styleType" minOccurs="0" maxOccurs="1"/>
        <xs:element name="column" type="columnType" minOccurs="1" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attribute name="id" type="xs:string" />
      <xs:attribute name="cssClass" type="xs:string"/>
      <xs:attribute name="mobile-columns-style" type="xs:boolean" />
      <xs:attribute name="sticky-beahvior" type="xs:boolean" />
      <xs:attribute name="profiles" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="cellType">
        <xs:sequence>
          <xs:element name="access-permissions" type="xs:string" minOccurs="0" maxOccurs="1" />
          <xs:element name="style" type="styleType" minOccurs="0" maxOccurs="1" />
          <xs:element name="portlet-application" type="portletApplicationType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="id" type="xs:string" />
        <xs:attribute name="col-span" default="1">
          <xs:simpleType>
            <xs:restriction base="xs:integer">
              <xs:minInclusive value="1"/>
              <xs:maxInclusive value="12"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:attribute>
        <xs:attribute name="row-span" default="1">
          <xs:simpleType>
            <xs:restriction base="xs:integer">
              <xs:minInclusive value="0"/>
              <xs:maxInclusive value="12"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:attribute>
        <xs:attribute name="cssClass" type="xs:string"/>
        <xs:attribute name="profiles" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="columnType">
        <xs:sequence>
          <xs:element name="access-permissions" type="xs:string" minOccurs="0" maxOccurs="1" />
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element name="portlet-application" type="portletApplicationType" minOccurs="1" maxOccurs="1" />
            <xs:element name="container" type="containerType" minOccurs="1" maxOccurs="1" />
          </xs:choice>
        </xs:sequence>
        <xs:attribute name="id" type="xs:string" />
        <xs:attribute name="col-span">
          <xs:simpleType>
            <xs:restriction base="xs:integer">
              <xs:minInclusive value="1"/>
              <xs:maxInclusive value="12"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:attribute>
        <xs:attribute name="cssClass" type="xs:string"/>
        <xs:attribute name="profiles" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="styleType">
      <xs:sequence>
          <xs:element name="margin-top" minOccurs="0" maxOccurs="1">
            <xs:simpleType>
              <xs:restriction base="xs:integer">
                <xs:pattern value="0|4|8|12|16|20" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="margin-bottom" minOccurs="0" maxOccurs="1">
            <xs:simpleType>
              <xs:restriction base="xs:integer">
                <xs:pattern value="0|4|8|12|16|20" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="margin-right" minOccurs="0" maxOccurs="1">
            <xs:simpleType>
              <xs:restriction base="xs:integer">
                <xs:pattern value="0|4|8|12|16|20" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="margin-left" minOccurs="0" maxOccurs="1">
            <xs:simpleType>
              <xs:restriction base="xs:integer">
                <xs:pattern value="0|4|8|12|16|20" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="radius-top-right" minOccurs="0" maxOccurs="1">
            <xs:simpleType>
              <xs:restriction base="xs:integer">
                <xs:pattern value="0|4|8|12|16|20" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="radius-top-left" minOccurs="0" maxOccurs="1">
            <xs:simpleType>
              <xs:restriction base="xs:integer">
                <xs:pattern value="0|4|8|12|16|20" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="radius-bottom-right" minOccurs="0" maxOccurs="1">
            <xs:simpleType>
              <xs:restriction base="xs:integer">
                <xs:pattern value="0|4|8|12|16|20" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="radius-bottom-left" minOccurs="0" maxOccurs="1">
            <xs:simpleType>
              <xs:restriction base="xs:integer">
                <xs:pattern value="0|4|8|12|16|20" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="mobile-hidden" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
          <xs:element name="border-color" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
      </xs:sequence>
    </xs:complexType>

    <xs:complexType name="portletPreferencesType">
        <xs:sequence>
            <xs:element name="preference" type="portletPreferenceType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="portletPreferenceType">
        <xs:sequence>
            <xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="value" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element name="read-only" type="xs:string" minOccurs="0" maxOccurs="1"/>
        </xs:sequence>
    </xs:complexType>

</xs:schema>
