1 Reply Latest reply on Jun 2, 2017 9:18 AM by Dan Florian

    Custom Node Definitions w/o namespace

    David Harrison Newbie

      Is it possible to define CNDs without referencing a custom namespace?  What are the implications if this is done?

       

      Several consumers of custom CNDs (via ModeShape REST API) have inquired about whether we really need a prefix and a colon in front of property names.They essentially want to automatically map Java object properties, by the same property name as the CND. However,  java doesn't support colons in variable names.

       

      ex:

      [car:Car] > nt:unstructured
        - car:maker (string)
        - car:model (string)
        - car:year (string) < '(19|20)\d{2}'                     // any 4 digit number starting with '19' or '20'
      ...
      
        • 1. Re: Custom Node Definitions w/o namespace
          Dan Florian Newbie

          Hi David,

           

          Yes you can define node properties without a namespace in your CNDs. Properties defined like this are said to have the default namespace. The default namespace is also called the "empty" namespace. For properties that have the default namespace, org.modeshape.jcr.AbstractJcrProperty.getNamespaceURI() will return the empty string (never null). Keep in mind, even though you might define all your properties to not have a namespace, your nodes may still have inherited properties that do have namespaces. For instance, all nodes have the jcr:primaryType property.

           

          Namespaced properties is a way to organize your properties into logical groups. This could help you when querying as you could search for nodes with specific namespace(s). Also, namespaces allow properties to have the same local part. Here's an example:

           

          [a:myNode]

            - a:value (string)

            - b:value (string)

           

          Hth,

           

          Dan