There are times when custom namespace is needed in a system for organization and management purposes. Without registering the namespace with CRX, properties with custom namespace would not be accepted. In this blog post I will talk about two ways of registering a namespace in CRX.
To illustrate, let’s take a look at the behavior of CRX without registering any namespace. Let me go ahead and enter a property that has namespace in it:
Upon saving, I would get the following error:
Now let’s proceed with registering the namespace. There are two ways of doing this:
Register namespace via CRX Console
- Namespace can be added via Node Type Administration in CRX Console.
- In the Node Type Administration window, click on “Namespaces” which is located at far right of the toolbar.
- At the bottom of the Namespaces window, click on “New”.
- Enter the URI and the Namespace mapping and click Ok. And you should see the namespace added:
- Voila! It’s that easy. And now you can add the property again with the registered namespace:
Register custom namespace via CND file
- Namespace can also be registered via a CND file. The CND file can be deployed with any CRX packages (install folder, or via the package manager).
- Once the package is installed on CRX, any namespaces in CND files found inside the package would be registered automatically.
- Here’s the content of the CND file:
- That’s it! It’s nothing more than a mapping=uri pair.