Transform XML using XSL, convert all elements to attributes

getanesortnow

New Member
I have the following XML file:-\[code\]<?xml version="1.0" encoding="UTF-8"?><viewentries> <viewentry position="1"> <entrydata columnnumber="0"> <text>Text1</text> </entrydata> <entrydata columnnumber="1"> <text>Text2</text> </entrydata> <entrydata columnnumber="2"> <text>Text3</text> </entrydata> </viewentry> <viewentry position="2"> <entrydata columnnumber="0"> <text>Text1</text> </entrydata> <entrydata columnnumber="1"> <text>Text2</text> </entrydata> <entrydata columnnumber="2"> <text>Text3</text> </entrydata> </viewentry></viewentries>\[/code\]I need to transform this XML file using an XSL stylesheet to the following:-\[code\]<?xml version="1.0" encoding="UTF-8"?><records> <record position="1" col0="Text1" col1="Text2" col2="Text3"/> <record position="2" col0="Text1" col1="Text2" col2="Text3"/></records>\[/code\]I have no real idea where to start.Each element needs to be converted to a element, pulling through the position attribute, however each needs to be made into the attribute name, and each child attribute needs to be made into the attribute value.Any help is greatly appreciated.
 
Back
Top