<?xml version="1.0" encoding="UTF-8"?>
<school>
<classes>
<class>
<name>DEPT-NAME</name>
<place>ROOM-NO</place>
</class>
</classes>
<alldata>
<data>
<value>CSE</value>
<value>101</value>
</data>
<data>
<value>IT</value>
<value>202</value>
</data>
</alldata>
<students>
<student>
<DEPT-NAME>CSE</DEPT-NAME>
<name>Jhon</name>
<roll>111</roll>
</student>
<student>
<DEPT-NAME>CSE</DEPT-NAME>
<name>Zubi</name>
<roll>112</roll>
</student>
<student>
<DEPT-NAME>IT</DEPT-NAME>
<name>Jack</name>
<roll>121</roll>
</student>
<student>
<DEPT-NAME>IT</DEPT-NAME>
<name>Razz</name>
<roll>122</roll>
</student>
</students>
</school>
I want a csv output like
- DEPT-NAME ROOM-NO NAME ROLLNO
- CSE 101 Jhon 111
- __________Zubi 112
- IT 202 Jack 121
- __________Razz 122
I was trying to do like this way but it did't work
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:text>SCHOOL</xsl:text>
<xsl:variable name="StudentCSE">
<xsl:for-each select="school/students/student[DEPT-NAME='CSE']">
<xsl:value-of select="name"/><xsl:text>,</xsl:text>
<xsl:value-of select="roll"/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="Value">
<xsl:for-each select="school/alldata/data">
<xsl:text>
</xsl:text>
<xsl:for-each select="value" >
<xsl:value-of select="."/><xsl:text>,</xsl:text>
</xsl:for-each>
<xsl:copy-of select="$StudentCSE"/>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="school/classes/class">
<xsl:text>
</xsl:text>
<xsl:value-of select="name"/><xsl:text>,</xsl:text>
<xsl:value-of select="place"/><xsl:text>,NAME,ROll</xsl:text>
<xsl:copy-of select="$Value"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>