Powered By

Free XML Skins for Blogger

Powered by Blogger

Wednesday, December 31, 2008

exists in XI Message Mappings

Use

Use this function to determine whether a particular source field exists in the XML instance to be processed. If it does, exists() returns the value true, otherwise it returns the value false.

Example

In the example below, a function description is to be mapped to a structure that merely comprises the technical name and the description of the function. The source structure field descriptionis optional, however, the target structure field descriptionOfUse is mandatory ( minOccurs = 1).

Source Structure (Left) and Target Structure (Right)

Field Name

minOccurs

maxOccurs

Field Name

min-
Occurs

max-
Occurs

FunctionDeclMsg

1

1

FunctionHeadingMsg

1

1

name

1

1

technicalName

1

1

description

0

1

descriptionOfUse

1

1

inputArg

0

64




name (Attr)

1

1




type (Attr)

1

1




returnValue

0

1




type (Attr)

1

1




Using the exists()function and other Boolean functions you can output a specified string by default if the description-tag does not exist here. This ensures that the target field descriptionOfUse is always completed and is never empty.

Message Mapping Using exists()

Target Field Mapping

Value of Constant()

/FunctionHeadingMsg=/FunctionDeclMsg


/FunctionHeadingMsg/technicalName=/FunctionDeclMsg/name


/FunctionHeadingMsg/descriptionOfUse=
if( Constant() , Not(exists(/FunctionDeclMsg/description)) , /FunctionDeclMsg/description
)

(No description available)

The text description of the if standard function must be read as follows: if( true>,
,
false>).

Example

Source Instance

Result

encoding="UTF-8"?>




myFunc


type="String"
name="arg1" />


type="String"
name="arg2" />


type="String"
name="arg3" />

encoding="UTF-8"?>


xmlns:ns0="workshopDemo">


myFunc


(No description available)

No comments: