I need to select attributes from my XML file and output the info into a table using XSL, need to output day name, instructor and class being taught, the problem is that I have multiple attirubtes within each group.

my XML:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="g4.xsl"?>
<schedule>
<student_info>
Vitaliy Berkovich 803-401-025
</student_info>
<info>
<day name ="Monday">
<Class name="Database Administration" Code="CPAN 315" Instructor="Paul Berger" Time="9:00-10:45" Location="E422">
</Class>
<Class name="Design Patterns and Software Testing" Code="CPAN 311" Instructor="Robert Robson" Time="10:50-12:35" Location="E417">
</Class>
<Class name="Requirements Analysis and Process Modelling(WI)" Code="CPAN 331" Instructor="Razieh Niazi" Time="2:30-4:15" Location="J129">
</Class>
</day>

<day name="Tuesday">
<Class name="XML" Code="CPAN 330" Instructor="Eric Dymond" Time="9:55-10:45" Location="E422">
</Class>
<Class name="Design Patterns and Software Testing" Code="CPAN 311" Instructor="Robert Robson" Time="10:50-12:35" Location="J132">
</Class>
<Class name="Android Programming" Code="CPAN 312" Instructor="Igor Pustylnick" Time="2:30-4:15" Location="E422">
</Class>
</day>

<day name="Wednesday">
<Class name="Open Source Programming" Code="CPAN 332" Instructor="Eric Dymond" Time="9:00-10:45" Location="E417">
</Class>
<Class name="Android Programming" Code="CPAN 312" Instructor="Igor Pustylnick" Time="11:45-1:30" Location="J132">
</Class>
<Class name="XML" Code="CPAN 330" Instructor="Eric Dymond" Time="1:35-3:20" Location="J132">
</Class>
</day>

<day name="Friday">
<Class name="Database Administration" Code="CPAN 315" Instructor="Paul Berger" Time="11:45-1:30" Location="J132">
</Class>
<Class name="Open Source Programming" Code="CPAN 332" Instructor="Eric Dymond" Time="1:35-3:20" Location="J132">
</Class>
<Class name="Requirements Analysis and Process Modelling(WI)" Code="CPAN 331" Instructor="Razieh Niazi" Time="4:20-6:05" Location="J130">
</Class>
</day>
</info>
</schedule>


my XSL: before it output only the days and 2 classes, now it won't work at all as I was messing around with it too much

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8"/>
<xsl:template match="info">
<html>
<head><title>Schedule</title>
</head>
<body>
<table width="100%" border="1">
<THEAD>
<TR>
<TD width="50%"><B>Day</B></TD>
<TD width="50%"><B>Instructor</B></TD>
<TD width="50%"><B>Class</B></TD>
</TR>
</THEAD>
<TBODY>

</TBODY>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="day">

<TR>
<TD width="25%"><xsl:sort select="@name" /></TD>
<TD width="25%"><xsl:value-of select="Class/@Instructor" /></TD>
<TD width="25%"><xsl:value-of select="Class/@name" /></TD>
</TR>

</xsl:template>
</xsl:stylesheet>

Because you actually made an effort to solve the problem yourself, and you have the right idea, I'll happily provide you with a solution. It's not the only solution, but it should give you the right ideas. Just put the result in an html document and you'll see it.

Also, please use Codeboxes when posting any of your documents or code.

Input Document

<schedule>
	<student_info>Vitaliy Berkovich 803-401-025</student_info>
	<info>
		<day name="Monday">
			<Class name="Database Administration" Code="CPAN 315" Instructor="Paul Berger" Time="9:00-10:45" Location="E422"/>
			<Class name="Design Patterns and Software Testing" Code="CPAN 311" Instructor="Robert Robson" Time="10:50-12:35" Location="E417"/>
			<Class name="Requirements Analysis and Process Modelling(WI)" Code="CPAN 331" Instructor="Razieh Niazi" Time="2:30-4:15" Location="J129"/>
		</day>
		<day name="Tuesday">
			<Class name="XML" Code="CPAN 330" Instructor="Eric Dymond" Time="9:55-10:45" Location="E422"/>
			<Class name="Design Patterns and Software Testing" Code="CPAN 311" Instructor="Robert Robson" Time="10:50-12:35" Location="J132"/>
			<Class name="Android Programming" Code="CPAN 312" Instructor="Igor Pustylnick" Time="2:30-4:15" Location="E422"/>
		</day>
		<day name="Wednesday">
			<Class name="Open Source Programming" Code="CPAN 332" Instructor="Eric Dymond" Time="9:00-10:45" Location="E417"/>
			<Class name="Android Programming" Code="CPAN 312" Instructor="Igor Pustylnick" Time="11:45-1:30" Location="J132"/>
			<Class name="XML" Code="CPAN 330" Instructor="Eric Dymond" Time="1:35-3:20" Location="J132"/>
		</day>
		<day name="Friday">
			<Class name="Database Administration" Code="CPAN 315" Instructor="Paul Berger" Time="11:45-1:30" Location="J132"/>
			<Class name="Open Source Programming" Code="CPAN 332" Instructor="Eric Dymond" Time="1:35-3:20" Location="J132"/>
			<Class name="Requirements Analysis and Process Modelling(WI)" Code="CPAN 331" Instructor="Razieh Niazi" Time="4:20-6:05" Location="J130"/>
		</day>
	</info>
</schedule>

Transformation

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output indent="yes" method="html" />

	<xsl:template match="/">
		<html>
			<head>
				<title>Schedule</title>
			</head>
			<body>
				<xsl:apply-templates select="schedule"/>
			</body>
		</html>
	</xsl:template>

	<xsl:template match="schedule">
		<xsl:apply-templates select="info"/>
	</xsl:template>

	<xsl:template match="info">
		<table width="100%" border="1">
			<thead>
				<tr>
					<th>Day</th>
					<th>Class</th>
					<th>Instructor</th>					
				</tr>
				<tbody>
					<xsl:apply-templates select="day" />
				</tbody>				
			</thead>
		</table>
	</xsl:template>

	<xsl:template match="day" >
		<xsl:apply-templates select="Class" />
	</xsl:template>

	<xsl:template match="Class">
		<tr>
			<td><xsl:value-of select="../@name"/></td>
			<td><xsl:value-of select="@name"/></td>
			<td><xsl:value-of select="@Instructor"/></td>
		</tr>
	</xsl:template>
</xsl:stylesheet>

Results

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Schedule</title>
  </head>
  <body>
    <table width="100%" border="1">
      <thead>
        <tr>
          <th>Day</th>
          <th>Class</th>
          <th>Instructor</th>
        </tr>
        <tbody>
          <tr>
            <td>Monday</td>
            <td>Database Administration</td>
            <td>Paul Berger</td>
          </tr>
          <tr>
            <td>Monday</td>
            <td>Design Patterns and Software Testing</td>
            <td>Robert Robson</td>
          </tr>
          <tr>
            <td>Monday</td>
            <td>Requirements Analysis and Process Modelling(WI)</td>
            <td>Razieh Niazi</td>
          </tr>
          <tr>
            <td>Tuesday</td>
            <td>XML</td>
            <td>Eric Dymond</td>
          </tr>
          <tr>
            <td>Tuesday</td>
            <td>Design Patterns and Software Testing</td>
            <td>Robert Robson</td>
          </tr>
          <tr>
            <td>Tuesday</td>
            <td>Android Programming</td>
            <td>Igor Pustylnick</td>
          </tr>
          <tr>
            <td>Wednesday</td>
            <td>Open Source Programming</td>
            <td>Eric Dymond</td>
          </tr>
          <tr>
            <td>Wednesday</td>
            <td>Android Programming</td>
            <td>Igor Pustylnick</td>
          </tr>
          <tr>
            <td>Wednesday</td>
            <td>XML</td>
            <td>Eric Dymond</td>
          </tr>
          <tr>
            <td>Friday</td>
            <td>Database Administration</td>
            <td>Paul Berger</td>
          </tr>
          <tr>
            <td>Friday</td>
            <td>Open Source Programming</td>
            <td>Eric Dymond</td>
          </tr>
          <tr>
            <td>Friday</td>
            <td>Requirements Analysis and Process Modelling(WI)</td>
            <td>Razieh Niazi</td>
          </tr>
        </tbody>
      </thead>
    </table>
  </body>
</html>

Thank you, I've been breaking my head for hours!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.