Skip to Content
avatar image
Former Member

Mapping doubt

Dear SDN,

I am trying to create a message mapping but I'm having problems. The source is of the form:

Source(1..1)

Line (1..unbounded)

Key (1..1)

Val (1..1)

And target is of the form:

Target(1..1)

Id (1..1)

Name (1..1)

Age (1..1)

An example of source could be

<Source>

<Line>

<Key>Name</Key>

<Val>Angie</Val>

</Line>

<Line>

<Key>Id</Key>

<Val>1002</Val>

</Line>

<Line>

<Key>Age</Key>

<Val>25</Val>

</Line>

</Source>

Target result should be

<Target>

<Id>1002</Id>

<Name>Angie</Name>

<Age>25</Age>

</Target>

Note that the mapping is from an 1..unbounded node to an 1:1 node, also note that tuples Key,Val are not sorted just like Target needed.

Any Ideas?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 01, 2006 at 05:30 PM

    Hi,

    Create user defined function with three inputs. Inside it use global object of type HashMap (package java.util.*).

    inputs:

    1) input key

    2) input value

    3) what to put into target

    Regards,

    Wojciech

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      Look at this

      if{hash==null){

      //here fill map

      }

      //here select from hash map, 3rd input should be a constant corresponding to which element you are mapping

      Regards,

      Wojciech

  • avatar image
    Former Member
    Dec 01, 2006 at 05:34 PM

    THis is an XSLT scenario. Java code can get complex whereas with XSLT and right tools, it is quite easy and maintainable

    Add comment
    10|10000 characters needed characters exceeded