Skip to Content
avatar image
Former Member

XSLT mapping

Hi Expertise,

Please give me the XSLT mapping to get the desired output for the specified input format.(to group based on the field "group")

Input:

<item>

<group>1</group>

<name>item-1<//name>

<cost>12.22</cost>

</item>

<item>

<group>2</group>

<name>item-2<//name>

<cost>12.22</cost>

</item>

<item>

<group>2</group>

<name>item-3<//name>

<cost>12.22</cost>

</item>

<item>

<group>1</group>

<name>item-4<//name>

<cost>12.22</cost>

</item>

<item>

<group>2</group>

<name>item-5<//name>

<cost>12.22</cost>

</item>

Output required:

<group>

<item>

<group>1</group>

<name>item-1<//name>

<cost>12.22</cost>

</item>

<item>

<group>1</group>

<name>item-4<//name>

<cost>12.22</cost>

</item>

</group>

<group>

<item>

<group>2</group>

<name>item-2<//name>

<cost>12.22</cost>

</item>

<item>

<group>2</group>

<name>item-3<//name>

<cost>12.22</cost>

</item>

<item>

<group>2</group>

<name>item-5<//name>

<cost>12.22</cost>

</item>

</group>

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Mar 13, 2008 at 08:51 PM

    Saravanan,

    Follow the below logic.

    
    item -----> item
    
    group[Change Context]------>Sort[Choose Numerical,Ascending]------> SplitByValue[EachValue]-----> group
    
    group[Change Context] & name[Change Context]------>Sort By Key[Choose Numerical,Ascending]------> SplitByValue[EachValue]-----> Name
    
    group[Change Context] & cost[Change Context]------>Sort By Key[Choose Numerical,Ascending]------> SplitByValue[EachValue]-----> cost
    
    

    I hope it helps!

    raj.

    Add comment
    10|10000 characters needed characters exceeded

    • Saravanan,

      Right click on group and choos Context ---> Now choose the Parent node of item.

      For example,

      <MT_Input>

      <Row>

      <item>

      <group/>

      ..

      ..

      </item>

      then, if you do right click on group and if you choose context, the default selected will be item, coz the item is the parent node for group. As in my example instead of item , choose it as Row.

      Sort By Key expects two input. Hence in the top node give group and the bottom node give name.

      Hope it helps, if not reply back.

      raj.

  • Mar 13, 2008 at 08:28 PM

    Saravanan,

    You are sorting and you are not grouping right? By the way just curiosity ,why don't you want to achieve this using Graphical Mapping?

    raj.

    Add comment
    10|10000 characters needed characters exceeded