////
   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.
////

*Tag:* namespace

[ivysettings.namespaces.namespace]#Defines a new namespace. A namespace is identified by a name, which can be referenced by one of the link:../settings/resolvers{outfilesuffix}[resolvers].#

An overview of namespaces is given in the link:../settings/namespaces{outfilesuffix}[namespaces] documentation.

A namespace mainly consists of a list of rules, each rule defining a translation between a system namespace and the defined namespace, and vice versa.

There are two main possibilities for using these rules. By default, a namespace iterates through the rules, and when it finds one that translates the given name, it returns the translated name. But the namespace can be configured to use the list as a translator chain: in this case, all rules are applied in order, the result of the first rule translation being passed to the second, and so on.

== Attributes


[options="header",cols="15%,50%,35%"]
|=======
|Attribute|Description|Required
|name|the namespace name|Yes
|chainrules|true to indicate that namespaces rules should be chained, false otherwise|No, defaults to false
|=======


== Child elements


[options="header"]
|=======
|Element|Description|Cardinality
|link:../settings/namespace/rule{outfilesuffix}[rule]|defines a new namespace rule|0..n
|=======


== Example


[source, xml]
----

<namespace name="test">
  <rule>
    <fromsystem>
      <src org="systemorg"/>
      <dest org="A"/>
    </fromsystem>
    <tosystem>
      <src org="A"/>
      <dest org="systemorg"/>
    </tosystem>
  </rule>
</namespace>

----


[source, xml]
----

<namespace name="test">
  <rule>
    <fromsystem>
      <src org="systemorg2" module="system\-(.+)"/>
      <dest org="B" module="$m1"/>
    </fromsystem>
    <tosystem>
      <src org="B" module=".+"/>
      <dest org="systemorg2" module="system-$m0"/>
    </tosystem>
  </rule>
</namespace>

----


[source, xml]
----

<namespace name="test" chainrules="true">
  <rule>
    <fromsystem>
      <src org="systemorg"/>
      <dest org="A"/>
    </fromsystem>
    <tosystem>
      <src org="A"/>
      <dest org="systemorg"/>
    </tosystem>
  </rule>
  <rule>
    <fromsystem>
      <src module="systemmod"/>
      <dest module="A"/>
    </fromsystem>
    <tosystem>
      <src module="A"/>
      <dest module="systemmod"/>
    </tosystem>
  </rule>
  <rule>
    <fromsystem>
      <src module="systemmod2"/>
      <dest module="B"/>
    </fromsystem>
    <tosystem>
      <src module="B"/>
      <dest module="systemmod2"/>
    </tosystem>
  </rule>
</namespace>

----
