cancel
Showing results for 
Search instead for 
Did you mean: 

cardinality & singleton

Former Member
0 Kudos

HI Friends

Can anyone explain me regarding "cardinality&Singleton"

with a small example

I have gone through some of the blogs but I am not getting that much clarity regarding these terms

Thanks in advance

Accepted Solutions (0)

Answers (4)

Answers (4)

amolgupta
Active Contributor
0 Kudos

hi,

CARDINALITY

in simple terms Cardinality tells how many instances of a node can exist.

0..1

0..n

1..1

1..n

a node tells the structure for example of a row in a table.

so there can be multiple rows with the same structure.

SINGLETON

when we use singleton....that means we will have only one instance of a node.

note that singleton option is not available to top level nodes directly under the main Context node.

regards,

-Ag.

Former Member
0 Kudos

Cardinality tells the relationship of a parent node with iths child whereas Singleton property tells about the relationship of a child node with its parent.

Former Member
0 Kudos

Hi

If a node or attribute has contextrootnode it's immediate parent node then it is called as Indipendent node or attribute.

otherwise dependent node or attribute.

A node collection is compose of elements.

An element is compose of it's immediate children (child node or value attribute)

Cardinality property controls the no of elements hold by the node at runtime.

Every node has the cardinality property of diff ranges are

0--1

0--n

1--1

1--n

Regards

Hazrath.G

Former Member
0 Kudos

Hi,

The cardinality property

The cardinality property is composed of a pair of values that control the maximum and minimum number of elements may contain at runtime. The cardinality property may have four possible values: • 0..1 Zero or one • 0..n Zero or more • 1..1 One and only one • 1..n One or more The first part of the cardinality describes the minimum number of element ’s element collection may contain. This value is either zero or one, and is stored as a Boolean value. This value can be obtained at runtime by calling the method node.getNodeInfo().isMandatory(). The second part of the cardinality describes the maximum number of elements ’s element collection may contain. This value is either a 1 or an n (meaning many) and is stored as a Boolean value (false = 1, true = n). This value can be obtained at runtime by calling method node.getNodeInfo().isMultiple(). If has a cardinality of 1..<something>, then it can be assumed that after the context has been initialised, there will be at least one element present in the node collection. This element is known as the default element and cannot be deleted!

If you attempt to perform some action on a node that would violate the constraints of the cardinality, then you will get a runtime exception in the context. E.G., trying to add a second element to a node of cardinality 0..1, or trying to delete the last element from a node of cardinality 1..n.

The singleton property

The singleton property critically affects the relationship between the child node and its parent node . If is declared at design time, then the generated interface for this node will vary depending on whether it is a singleton or non-singleton node.

Important:

• All non-singleton child nodes are associated with their parent node on a per parent element basis

There is a one-to-one relationship between each element in the parent node’s element collection and the corresponding child node.

If has n elements in its element collection, then you will have n distinct instances of the non-singleton child node . Non-singleton child nodes can be created by their respective parent element. • Singleton child nodes however, are associated with their parent node on a per node basis. Irrespective of the number of elements in the parent node’s element collection, there will only ever be one instance of the singleton child node .

The singleton child node holds the data relevant for the element at the lead selection in the parent node’s element collection.

Singleton child nodes must be created by their parent node. Since there can only ever be one instance of a singleton child node, it is impossible for an element in a parent node collection to create a singleton child node.

From Inside Webdynro For Java

Regards

Ayyapparaj