<?xml version="1.0"?>
<!--
  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.
-->

<!DOCTYPE tree-processor [
  <!ELEMENT tree-processor (language+)>
  <!ELEMENT language (namespace, file, parameter, roles, nodes)>
  <!ATTLIST language
    name CDATA #REQUIRED
    class CDATA #REQUIRED
    pool-max CDATA #IMPLIED
  >
  <!ELEMENT namespace EMPTY>
  <!ATTLIST namespace uri CDATA #REQUIRED>
  <!ELEMENT file EMPTY>
  <!ATTLIST file name CDATA #REQUIRED>
  <!ELEMENT parameter EMPTY>
  <!ATTLIST parameter element CDATA #REQUIRED>
  <!ELEMENT roles (role+)>
  <!ELEMENT role (hint*)>
  <!ATTLIST role
    name CDATA #REQUIRED
    shorthand CDATA #REQUIRED
    default-class CDATA #REQUIRED
  >
  <!ELEMENT hint EMPTY>
  <!ATTLIST hint
    shorthand CDATA #REQUIRED
    class CDATA #REQUIRED
  >
  <!ELEMENT nodes (node+)>
  <!ELEMENT node (allowed-children*, ignored-children*, forbidden-children*)>
  <!ATTLIST node
    name CDATA #REQUIRED
    builder CDATA #REQUIRED
  >
  <!ELEMENT allowed-children (#PCDATA)>
  <!ELEMENT ignored-children (#PCDATA)>
  <!ELEMENT forbidden-children (#PCDATA)>
]>

<!--+
    | $Id: treeprocessor-builtins.xml 433543 2006-08-22 06:22:54Z crossley $
    +-->
<tree-processor>
  <!--+
      | The sitemap language.
      | The "class" attribute names the implementation of TreeBuilder to be used for this language
      |
      | A language definition is a component of a ComponentSelector. Consequently, it can
      | have all attributes supported by components, including pool-settings.
      | Since it is unlikely that several sitemaps will be built simultaneously, the
      | pool-max is set to 1, meaning that only one builder is recycled.
      +-->
  <language name="sitemap"
            class="org.apache.cocoon.components.treeprocessor.sitemap.SitemapLanguage"
            pool-max="1">

    <!-- Namespace for this language -->
    <namespace uri="http://apache.org/cocoon/sitemap/1.0"/>

    <!-- File name for files in this language, relative to the environment prefix -->
    <file name="sitemap.xmap"/>

    <!-- Description of the element for nodes parameters -->
    <parameter element="parameter"/>

    <!-- New roles available to components created within a sitemap (i.e. in <map:components>) -->
    <roles>
      <role name="org.apache.cocoon.acting.ActionSelector"
            shorthand="actions"
            default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>

      <role name="org.apache.cocoon.selection.SelectorSelector"
            shorthand="selectors"
            default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>

      <role name="org.apache.cocoon.components.pipeline.ProcessingPipelineSelector"
            shorthand="pipes"
            default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>

      <role name="org.apache.cocoon.matching.MatcherSelector"
            shorthand="matchers"
            default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector">

        <!-- since <map:components> is a regular xconf, we can define shorthand for
             well-known implementations.

             The hint below allows the following to be written in <map:matchers> :
               <regexp-uri-matcher name="regexp"/>
             in place of :
               <map:matcher name="regexp" src="org.apache.cocoon.matching.RegexpURIMatcher"/>
          -->
        <hint shorthand="regexp-uri-matcher"
              class="org.apache.cocoon.matching.RegexpURIMatcher"/>

        <hint shorthand="wildcard-uri-matcher"
              class="org.apache.cocoon.matching.WildcardURIMatcher"/>

      </role>

      <role name="org.apache.cocoon.generation.GeneratorSelector"
            shorthand="generators"
            default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector">

        <hint shorthand="file-generator"
              class="org.apache.cocoon.generation.FileGenerator"/>

        <hint shorthand="XSP-generator"
              class="org.apache.cocoon.generation.ServerPagesGenerator"/>
      </role>

      <role name="org.apache.cocoon.transformation.TransformerSelector"
            shorthand="transformers"
            default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector">

        <hint shorthand="XSLT-transformer"
              class="org.apache.cocoon.transformation.TraxTransformer"/>

        <hint shorthand="cinclude-transformer"
              class="org.apache.cocoon.transformation.CIncludeTransformer"/>

      </role>

      <role name="org.apache.cocoon.serialization.SerializerSelector"
            shorthand="serializers"
            default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>

      <role name="org.apache.cocoon.reading.ReaderSelector"
            shorthand="readers"
            default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>

      <role name="org.apache.cocoon.components.notification.NotifyingBuilder"
            shorthand="notifying-builder"
            default-class="org.apache.cocoon.components.notification.DefaultNotifyingBuilder"/>

    </roles>

    <!--+
        | Node definitions for the sitemap language.
        +-->
    <nodes>
      <!-- A node has the following attributes :
           - name : the node name, given as a local name in the language namespace (no prefix)
           - builder : the class name of the ProcessingNodeBuilder for this node

           The contents of a node definition is the configuration of Configurable
           ProcessingNodeBuilders.
        -->

      <!-- Sitemap root node -->
      <node name="sitemap" builder="org.apache.cocoon.components.treeprocessor.sitemap.SitemapNodeBuilder">
        <allowed-children>components, views, action-sets, resources, flow, pipelines</allowed-children>
      </node>

      <node name="components" builder="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsNodeBuilder"/>

      <node name="views" builder="org.apache.cocoon.components.treeprocessor.CategoryNodeBuilder">
        <allowed-children>view</allowed-children>
      </node>

      <node name="view" builder="org.apache.cocoon.components.treeprocessor.sitemap.ViewNodeBuilder"/>

      <node name="action-sets" builder="org.apache.cocoon.components.treeprocessor.CategoryNodeBuilder">
        <allowed-children>action-set</allowed-children>
      </node>

      <node name="action-set" builder="org.apache.cocoon.components.treeprocessor.sitemap.ActionSetNodeBuilder"/>

      <node name="resources" builder="org.apache.cocoon.components.treeprocessor.CategoryNodeBuilder">
        <allowed-children>resource</allowed-children>
      </node>

      <node name="resource" builder="org.apache.cocoon.components.treeprocessor.NamedContainerNodeBuilder"/>

      <node name="flow" builder="org.apache.cocoon.components.treeprocessor.sitemap.FlowNodeBuilder">
        <allowed-children>script</allowed-children>
      </node>

      <node name="script" builder="org.apache.cocoon.components.treeprocessor.sitemap.ScriptNodeBuilder"/>

      <node name="pipelines" builder="org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNodeBuilder">
        <allowed-children>pipeline, handle-errors</allowed-children>
        <ignored-children>component-configurations</ignored-children>
      </node>

      <node name="pipeline" builder="org.apache.cocoon.components.treeprocessor.sitemap.PipelineNodeBuilder">
        <forbidden-children>sitemap, components, pipeline</forbidden-children>
      </node>

      <node name="match" builder="org.apache.cocoon.components.treeprocessor.sitemap.MatchNodeBuilder">
        <forbidden-children>sitemap, components, pipeline, handle-errors</forbidden-children>
      </node>

      <node name="select" builder="org.apache.cocoon.components.treeprocessor.sitemap.SelectNodeBuilder">
        <forbidden-children>sitemap, components, pipeline, handle-errors</forbidden-children>
      </node>

      <node name="act" builder="org.apache.cocoon.components.treeprocessor.sitemap.ActNodeBuilder">
        <forbidden-children>sitemap, components, pipeline, handle-errors</forbidden-children>
      </node>

      <node name="redirect-to" builder="org.apache.cocoon.components.treeprocessor.sitemap.RedirectToNodeBuilder"/>

      <node name="call" builder="org.apache.cocoon.components.treeprocessor.sitemap.CallNodeBuilder"/>

      <node name="mount" builder="org.apache.cocoon.components.treeprocessor.sitemap.MountNodeBuilder"/>

      <node name="read" builder="org.apache.cocoon.components.treeprocessor.sitemap.ReadNodeBuilder"/>

      <node name="aggregate" builder="org.apache.cocoon.components.treeprocessor.sitemap.AggregateNodeBuilder"/>

      <node name="generate" builder="org.apache.cocoon.components.treeprocessor.sitemap.GenerateNodeBuilder"/>

      <node name="transform" builder="org.apache.cocoon.components.treeprocessor.sitemap.TransformNodeBuilder"/>

      <node name="serialize" builder="org.apache.cocoon.components.treeprocessor.sitemap.SerializeNodeBuilder"/>

      <node name="handle-errors" builder="org.apache.cocoon.components.treeprocessor.sitemap.HandleErrorsNodeBuilder"/>

    </nodes>

  </language>

</tree-processor>
