<?xml version="1.0" encoding="UTF-8"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
-->

<schema xmlns="http://www.w3.org/2001/XMLSchema" 
    xmlns:configuration="http://db.apache.org/torque/4.0/generator/configuration"
    targetNamespace="http://db.apache.org/torque/4.0/generator/configuration"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified">

  <element name="outlets">
    <complexType>
      <sequence>
        <element name="outlet" type="configuration:baseOutlet" maxOccurs="unbounded"/>
        <!-- 
          The mergepoints defined here must be fully qualified with the name of the outlet.
          The mergepoint must already be known at this time. This is only ensured if the
          outlet is defined in the same file (then the definition of the mergepoint
          outside the outlet does not make sense) or in a parent module.
          The mergepoint definition here overrides any previous definition.
         -->
        <element name="mergepoint" type="configuration:mergepoint" minOccurs="0" maxOccurs="unbounded"/>
      </sequence>
    </complexType>
  </element>

  <complexType name="baseOutlet" abstract="true">
    <sequence>
      <element name="input" type="configuration:input" minOccurs="0"/>
      <element name="mergepoint" type="configuration:mergepoint" minOccurs="0" maxOccurs="unbounded" />
    </sequence>
    <!--  
      name can be optional, e.g. for filenameOutlets and for template outlets.
    -->
    <attribute name="name" type="string" use="optional"/>
  </complexType>

  <complexType name="javaOutlet">
    <complexContent>
      <extension base="configuration:baseOutlet">
        <sequence>
          <any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
        </sequence>
        <attribute name="class" type="string" use="required"/>
      </extension>
    </complexContent>
  </complexType>

  <complexType name="velocityOutlet">
    <complexContent>
      <extension base="configuration:baseOutlet">
        <attribute name="path" type="string" use="required"/>
        <attribute name="optionsInContext" type="string" use="optional"/>
        <attribute name="sourceAttributesInContext" type="string" use="optional"/>
        <attribute name="variablesInContext" type="string" use="optional"/>
        <attribute name="encoding" type="string" use="optional"/>
      </extension>
    </complexContent>
  </complexType>
  
  <complexType name="groovyOutlet">
    <complexContent>
      <extension base="configuration:baseOutlet">
        <attribute name="path" type="string" use="required"/>
        <attribute name="optionsInBinding" type="string" use="optional"/>
        <attribute name="sourceAttributesInBinding" type="string" use="optional"/>
        <attribute name="variablesInBinding" type="string" use="optional"/>
        <attribute name="encoding" type="string" use="optional"/>
        <!-- 
          Whether the outlet is a script(false) or template (true) 
          If not set, the type is retrieved from the path ending. 
          If the path ends with ".groovy" it is a script,
          in all other cases it is a template;
          -->
        <attribute name="template" type="boolean" use="optional"/>
      </extension>
    </complexContent>
  </complexType>
  
  <complexType name="copyOutlet">
    <complexContent>
      <extension base="configuration:baseOutlet">
        <attribute name="path" type="string" use="required"/>
      </extension>
    </complexContent>
  </complexType>
  
  <!-- Defines the input accepted by the outlet.
    Either the name of a source element (in case of an untyped model)
    or the class name of a model class (in the case of a typed model)
    must be given.
  -->
  <complexType name="input">
    <!-- Exactly one of the attributes must be set -->
    <attribute name="elementName" use="optional" />
    <attribute name="class" use="optional" />
  </complexType>

  <complexType name="mergepoint">
    <sequence>
      <element name="action" type="configuration:baseAction" minOccurs="0" maxOccurs="unbounded" /> 
    </sequence>
    <attribute name="name" use="required" />
  </complexType>

  <complexType name="baseAction" abstract="true">
  </complexType>

  <complexType name="applyAction">
    <complexContent>
      <extension base="configuration:baseAction">
        <attribute name="outlet" type="string" use="required"/>
        <attribute name="acceptNotSet" type="boolean" use="optional"/>
      </extension>
    </complexContent>
  </complexType>

  <complexType name="optionAction">
    <complexContent>
      <extension base="configuration:baseAction">
        <attribute name="option" type="string" use="required"/>
        <attribute name="acceptNotSet" type="boolean" use="optional"/>
      </extension>
    </complexContent>
  </complexType>

  <complexType name="outputAction">
    <complexContent>
      <extension base="configuration:baseAction">
        <attribute name="value" type="string" use="required"/>
      </extension>
    </complexContent>
  </complexType>

  <complexType name="sourceElementAttributeAction">
    <complexContent>
      <extension base="configuration:baseAction">
        <attribute name="element" type="string" use="required"/>
        <attribute name="attribute" type="string" use="optional"/>
        <attribute name="acceptNotSet" type="boolean" use="optional"/>
      </extension>
    </complexContent>
  </complexType>

  <complexType name="traverseAllAction">
    <complexContent>
      <extension base="configuration:baseAction">
        <attribute name="element" type="string" use="required"/>
        <attribute name="outlet" type="string" use="required"/>
      </extension>
    </complexContent>
  </complexType>

</schema>