2.1 :action()

There are two different forms of the :action() method:

2.1.1 :action() (mapping)

During a transformation, this method determines how data is transformed at particular nodes, that is how the data from the Src parameter is passed to the Dest parameter.

Each mapping object possesses an :action() method, which in its default implementation simply returns true. The method can be redefined (similar to :init()). This enables to define, in which way the data from the Src parameter is processed before it is transferred to the Dest parameter.

The :action() method is invoked from the parent transformer of the mapping object (to be more precisely from the :action() method of this transformer), when a node of an XML tree or an IDM object hierarchy matches the corresponding mapping object. Please refer to chapter “The transformer Object” of manual “XML Interface” for further details.

Definition

boolean :action
(
  anyvalue Src  input,
  anyvalue Dest input output
)

Parameters

anyvalue Src input

In this parameter the current node, which just is to be transformed, is passed. There are two different cases:

  • Transformation of an XML tree:

    In Src a doccursor that points to the current node is passed.

  • Transformation of an IDM object hierarchy:

    In Src an IDM object that represents the current node is passed.

anyvalue Dest input output
In this parameter the value is transferred, which has been passed as Dest with the invocation of :apply() or has been changed in one of the previous calls of :action() methods.

Return value

When the method returns true, it is assumed that the node has been processed completely and no more mapping objects are tested whether they match that node. Thus no further :action() methods will be called even though other matching mapping objects may exist.

When the method returns false, the current node is compared to the other mapping objects whose :action() methods will be invoked if applicable.

Objects with this method

mapping

2.1.2 :action() (transformer)

This method is invoked from the :apply() method of the transformer for each visited node of an XML tree or an IDM object hierarchy. The method then has to check all mapping children of the transformer whether the patterns in their .name attributes match the current node (Src parameter). The sequence for checking the mapping objects is determined by the sequence they are defined in the .mapping[] vector, with inherited mapping objects being checked last.

Attention

Inherited mapping objects are not contained in the .mapping[] vector of the parent. Therefore, they can only be accessed through the inheritance hierarchy. This is different from usual IDM inheritance.

When a match is found, the :action() method of the corresponding mapping object is called with the Src and Dest parameters simply passed on. The return value of this :action() method determines if the remaining mapping objects are checked and their :action() methods are also called for this node if applicable (return value false), or whether the node is considered as completed and the :action() method of the transformer is finished (return value true).

The method can be redefined (similar to :init()).

Definition

boolean :action
(
  anyvalue Src  input,
  anyvalue Dest input output
)

Parameters

anyvalue Src input

In this parameter, the node to be examined is passed.

  • When the .root attribute of the transformer contains a string, a doccursor that points to the XML node is expected. This node will then be compared to the mapping objects.
  • When the .root attribute of the transformer contains an IDM object, the IDM object that represents the current node is expected. This object will then be compared to the mapping objects.
anyvalue Dest input output
In this parameter the value is transferred, which has been passed as Dest with the invocation of :apply() or has been changed in one of the previous calls of :action() methods.

Return value

The method returns true if processing was completed without errors, false otherwise.

Objects with this method

transformer