| # XMLmind XML Editor - Online Help |

## 3. The "Declare Namespace" dialog box

This dialog box can be used

- To declare a namespace used by the name of an attribute or an element (it is required to do so before adding the element or the attribute) or used in the value of the attribute or in the textual content of the element (for example, when the document being edited is a schema).

  In practice, this is very rarely needed because document templates generally contain declarations for all the namespaces they might use.

- To change the ``prefix'' of a namespace.

  What is called a ``prefix'' here should be called the nickname or the mnemonic of the namespace. Without nickname "`xsi`" for namespace "`http://www.w3.org/2001/XMLSchema-instance`", an attribute name such as "`xsi:schemaLocation`" would be displayed as "`{http://www.w3.org/2001/XMLSchema-instance}schemaLocation`" by the GUI of XXE, which is quite unreadable.

  Real namespace prefixes only exist while the document is being loaded and while the document is being saved. Do not try to add an `xmln` attribute to elements to specify an namespace and its prefix. XXE does this automatically each time the document is saved, the nicknames declared using this dialog box being used preferably to automatically generated prefixes such as `ns`, `ns2`, `ns3`, etc.

- To make a namespace the ``default'' namespace, that is the namespace for which no prefix is displayed (for element names, not for attribute names).

  It is not recommended to mark a namespace as being ``default'' if some elements in the document have names without a namespace. In such case, it would be impossible to tell if name "`title`" is "`title`" with no namespace or is in fact "`{http://www.foo.com/namespace}title`", where "`http://www.foo.com/namespace`" has been marked as being the default namespace.

However, when the current document is conforming to a DTD, this dialog box can only be used to view the namespaces and their prefixes and not to edit them.

Procedure for declaring a namespace:

1. You may have to clear the form by clicking on the Cancel button

2. Specify the URI of the namespace in the Namespace field.

3. Specify the ``prefix'' of the namespace in the Prefix field.

   Specifying a prefix is mandatory even if the namespace is to be marked as ``default''.

4. Optionally mark it as being the `default'' namespace by checking the Default toggle.

5. Type Enter in any field or click on the OK button.

Procedure for changing the declaration of a namespace:

1. Select the namespace declaration to be edited by clicking on its row in the table.

2. Specify the ``prefix'' of the namespace in the Prefix field.

   Specifying a prefix is mandatory even if the namespace is to be marked as ``default''.

3. Optionally mark it as being the ``default'' namespace by checking the Default toggle.

4. Type Enter in any field or click on the OK button.