How to arrange and group elemets by using predefined rule?

ZressE

New Member
Good day!I'm trying to build up an xsl transformation file that do the next: There is an element that has a bunch of child elements of the type Characteristic. Each of them has its unique Name. I also have a list that describes the logical connection between some of Names and a certain named Characteristic sets (called Datasets):CharacteristicName : DatasetName
−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Att1_DS1                 : DS1
Att2_DS1                 : DS1
Att1_DS2                 : DS2
Att2_DS2                 : DS2I have to transform the xml so the main element should get new elements of type \[code\]<Dataset>\[/code\]. These Dataset with ids from the table should appear if the listed Characteristic Names appear in the source document. And then the corresponding Characteristics are copyed to these Dataset elements/If some Characteristic Name is not listed in the table so it should be placed in the Dataset with the id "Other"Source XML:\[code\]<Object> <ID>Obj1</ID> <!--DS1--> <Characteristic> <Name>Att1_DS1</Name> <Value>25</Value> </Characteristic> <!--DS2--> <Characteristic> <Name>Att1_DS2</Name> <Value>25</Value> </Characteristic> <!--DS1--> <Characteristic> <Name>Att2_DS1</Name> <Value>ABC</Value> </Characteristic> <!--DS2--> <Characteristic> <Name>Att2_DS2</Name> <Value>ABC</Value> </Characteristic> <!--Other--> <Characteristic> <Name>Att3_NN</Name> <Value>25</Value> </Characteristic> </Object>\[/code\]It should be transformed to:\[code\]<Object> <ID>Obj1</ID> <Dataset id="DS1"> <Characteristic> <Name>Att1_DS1</Name> <Value>25</Value> </Characteristic> <Characteristic> <Name>Att2_DS1</Name> <Value>ABC</Value> </Characteristic> </Dataset> <Dataset id="DS2"> <Characteristic> <Name>Att1_DS1</Name> <Value>25</Value> </Characteristic> <Characteristic> <Name>Att2_DS1</Name> <Value>ABC</Value> </Characteristic> </Dataset> <Dataset id="Other"> <Characteristic> <Name>Att3_NN</Name> <Value>25</Value> </Characteristic> </Dataset></Object>\[/code\]Could you please help me doing these. Any tips or ideas which direction should I move?
 
Back
Top