XSLT Consolidating data when ID is the same

chimchuot05

New Member
I am having some issues with consuming an XML and applying multiple conditions on it. I have an input XML that looks like this:\[code\]<?xml version="1.0" encoding="UTF-8"?><results xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ResultsType"> <result> <resultSets> <resultSet> <row> <column1>11111</column1> <column2>0</column2> <column3>imageId/111111</column3> <column4>2012-04-03T10:11:22.187</column4> </row> <row> <column1>11111</column1> <column2>2</column2> <column3>imageId/111112</column3> <column4>2012-04-03T10:11:22.187</column4> </row> <row> <column1>11111</column1> <column2>2</column2> <column3>imageId/111113</column3> <column4>2012-04-03T10:11:22.187</column4> </row> <row> <column1>22222</column1> <column2>0</column2> <column3>imageId/222222</column3> <column4>2012-04-03T10:11:22.187</column4> </row> <row> <column1>22222</column1> <column2>2</column2> <column3>imageId/222223</column3> <column4>2012-04-03T10:11:22.187</column4> </row> </resultSet> </resultSets> </result></results>\[/code\]However i would like it to look like this:\[code\]<?xml version="1.0" encoding="UTF-8"?><results xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ResultsType"> <result> <row> <id>11111</id> <lagrgeImage>imageId/111111</lagrgeImage> <smallImage>imageId/111112</smallImage> <smallImage>imageId/111113</smallImage> </row> <row> <id>22222</id> <lagrgeImage>imageId/222222</lagrgeImage> <smallImage>imageId/222223</smallImage> </row> </result></results>\[/code\]As you can see there are two filtering condition:If column2 = 0 then largeImage tag is needed in the output however column2 = 2 then smallImage tag is needed in the output.UPDATEBoth of the examples below worked perfectly, however they are both including namespacing in the root that are unexpected. The output i get is:\[code\]<?xml version="1.0" encoding="utf-8"?><results xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ResultsType"> <result> <row> <id>11111</id> <largeImage>imageId/111111</largeImage> <smallImage>imageId/111112</smallImage> <smallImage>imageId/111113</smallImage> </row> <row> <id>22222</id> <largeImage>imageId/222222</largeImage> <smallImage>imageId/222223</smallImage> </row> </result></results>\[/code\]How do i remove \[code\]xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ResultsType"\[/code\] from the above output?
 
Back
Top