We help IT Professionals succeed at work.
Get Started

Listing items

363 Views
Last Modified: 2013-11-18
I'm new to using xsl and wonder if someone could help me with something quite urgent.

I have attached the code, which generates a list of student coures, assigning a css class depending on what teamcode it is, S44, S45 etc.

However, the list is displaying like this..

Course 1 (S44)
Course 2 (S44)
Course 3 (S45)
Course 4 (S45)

What I need is for them to display like this...

S44
Course 1
Course 2

S45
Course 3
Course 4

Could someone assist with perhaps some modified code to get this to display correctly?

Much much thanks

:-)
<?xml version="1.0" encoding="UTF-8"?><!-- DWXMLSource="../xml/SearchCourse-3.xml" -->
<!DOCTYPE xsl:stylesheet  [
	<!ENTITY nbsp   "&#160;">
	<!ENTITY copy   "&#169;">
	<!ENTITY reg    "&#174;">
	<!ENTITY trade  "&#8482;">
	<!ENTITY mdash  "&#8212;">
	<!ENTITY ldquo  "&#8220;">
	<!ENTITY rdquo  "&#8221;"> 
	<!ENTITY pound  "&#163;">
	<!ENTITY yen    "&#165;">
	<!ENTITY euro   "&#8364;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8"/>
<xsl:param name="host" />
<xsl:template match="ArrayOfCourseSearchItem">
    <nav><ul>
    <xsl:for-each select="CourseSearchItem">
    <xsl:sort select="TeamCode" order="ascending"/>
    <xsl:if test="ShowOnWeb = 'true'">
          <xsl:choose>
            <xsl:when test="(TeamCode ='S41') or (TeamCode ='S42') or (TeamCode ='S43') or (TeamCode ='S44') or (TeamCode ='S45') or (TeamCode ='S46')">
            		<li class="business" >
            			<a>
                            <xsl:attribute name="href">
                                <xsl:value-of select="$host" />
                                <xsl:text disable-output-escaping="no">details/</xsl:text>
                                <xsl:text disable-output-escaping="no">business/</xsl:text>
                                <xsl:value-of select="CourseCode"/>
                            </xsl:attribute>
                                <xsl:attribute name="class">
                                <xsl:text disable-output-escaping="no">business</xsl:text>
                            </xsl:attribute>
                            <xsl:value-of select="CourseTitle"/>
                        </a><span class="grey small"> - <xsl:value-of select="LocationName"/></span>
           			 </li>
            </xsl:when>
            <xsl:when test="(TeamCode ='S31') or (TeamCode ='S32') or (TeamCode ='S33') or (TeamCode ='S34') or (TeamCode ='S36')">
                        <li class="service">
                        <a>
                        <xsl:attribute name="href">
                            <xsl:value-of select="$host" />
                            <xsl:text disable-output-escaping="no">details/</xsl:text>
                            <xsl:text disable-output-escaping="no">service/</xsl:text>
                            <xsl:value-of select="CourseCode"/>
                        </xsl:attribute>
                        <xsl:attribute name="class">
                            <xsl:text disable-output-escaping="no">service</xsl:text>
                        </xsl:attribute>
                        <xsl:attribute name="title">
                            <xsl:value-of select="CourseTitle" />
                            <xsl:text> - </xsl:text>
                            <xsl:value-of select="LocationName" />
                            <xsl:text> - </xsl:text>
                            <xsl:value-of select="TeamCode" />
                            <xsl:text disable-output-escaping="no"> - </xsl:text>
                            <xsl:value-of select="CourseCode"/>
                        </xsl:attribute>
                        <xsl:value-of select="CourseTitle"/>
                        </a><span class="grey small"> - <xsl:value-of select="LocationName"/></span>
                        </li>
            </xsl:when>
            <xsl:otherwise>
            <li class="engineering">
            <a>
              <xsl:attribute name="href">
                <xsl:value-of select="$host" />
                <xsl:text disable-output-escaping="no">details/</xsl:text>
                <xsl:text disable-output-escaping="no">engineering/</xsl:text>
                <xsl:value-of select="CourseCode"/>
            </xsl:attribute>
            <xsl:attribute name="title">
                <xsl:value-of select="CourseTitle" />
                <xsl:text> - </xsl:text>
                <xsl:value-of select="LocationName" />
                <xsl:text> - </xsl:text>
                <xsl:value-of select="TeamCode" />
                <xsl:text disable-output-escaping="no"> - </xsl:text>
                <xsl:value-of select="CourseCode"/>
            </xsl:attribute>
            <xsl:attribute name="class">
                <xsl:text disable-output-escaping="no">engineering</xsl:text>
            </xsl:attribute>
            <xsl:value-of select="CourseTitle"/>
       		</a><span class="grey small"> - <xsl:value-of select="LocationName"/></span>
            </li>
            </xsl:otherwise>
          </xsl:choose>
      </xsl:if>
      </xsl:for-each>
      </ul></nav>
</xsl:template>
</xsl:stylesheet>

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE