Powered By

Free XML Skins for Blogger

Powered by Blogger

Wednesday, December 31, 2008

createIf inUse You use createIf() to create a tag in the target structure independently of a condition. Example In the example XI Message Mappings

Use

You use createIf() to create a tag in the target structure independently of a condition.

Example

In the example below, a mapping is required between two different formats for a list of messages. The attribute type is used in the source structure to classify the message as either internal (type="internal") or external (type="external"). However, in the target structure the tag internalRequest or externalRequest is used:

Source Structure (left) and Target Structure (right)

Field Name

minOccurs

maxOccurs

Field Name

minOccurs

maxOccurs

RequestListMsg

1

1

RequestListEIMsg

1

1

request

0

unbounded

internalRequest

0

unbounded

type (Attr.)

1

1

initiator

1

1

creator

1

1

contact

1

1

contact

1

1

issue

1

1

description

1

1

externalRequest

0

unbounded




initiator

1

1




contact

1

1




issue

1

1

You use createIf() to create the respective target field independently of attribute type:

Message Mapping Using createIf()

Target Field Mapping

Value of Constant()

/RequestListEIMsg=/RequestListMsg


/RequestListEIMsg/internalRequest=
createIf(
equalsS(
removeContexts(/RequestListMsg/request/type),
Constant()))

internal

/RequestListEIMsg/internalRequest/initiator=
/RequestListMsg/request/creator


/RequestListEIMsg/internalRequest/contact=
/RequestListMsg/request/contact


/RequestListEIMsg/internalRequest/issue=
/RequestListMsg/request/description


/RequestListEIMsg/internalRequest=
createIf(
equalsS(
removeContexts(/RequestListMsg/request/type),
Constant()))

external

/RequestListEIMsg/externalRequest/initiator=
/RequestListMsg/request/creator


/RequestListEIMsg/externalRequest/contact=
/RequestListMsg/request/contact


/RequestListEIMsg/externalRequest/issue=
/RequestListMsg/request/description


Note

The function removeContexts() is required because the attribute type is mapped in place of the source field request. Therefore, there is no target field for request and no context in the target structure. However, the type queue has nevertheless saved the request context so that processing would terminate early if you did not delete this context.

Example

Source Instance

Result

encoding="UTF-8"?>

internal">


creator1


contact1


description1

external">


creator2


contact2


description2

encoding="UTF-8"?>


xmlns:ns0="workshopDemo">


creator1


contact1


description1

<externalRequest>


creator2


contact2


description2

No comments: