How to Show...

Hey guys,

i am quite new in XSL, so i started learn it a bit.
although i am quite confuse.

i want to show this XML data in my web page (html)

<?xml version="1.0"?>
<?xml:stylesheet type="text/xsl" href="school.xsl"?>

<schools>

<school name="eldad">
cool school!!
<teachers>23</teachers>
<classes>40</classes>
<class_type>MATH</class_type>
<class_type>ART</class_type>
<max_age>4</max_age>
<closing>12.5.2002</closing>
</school>

<school name="gotman">
<teachers>40</teachers>
<classes>56</classes>
<class_type>PHYSIC</class_type>
<class_type>MATH</class_type>
<class_type>ART</class_type>
<min_age>2</min_age>
<max_age>15</max_age>
</school>

</schools>

what i want to do is to display the info like this:

Name:eldad // write optional data here i.e: "cool school!!"
Teachers:23
Classes: 40
...
...

but in my xml file there is a text that is not belong to any tag,
for example check the cool school!! string, its located in the <school>
but i am not able to display it properlly without all info got badly formated.

here is my xml code so far:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="schools">
<html>
<body>
<table width="500" style="border: solid blue 1px;">
<tr>
<td>
<xsl:apply-templates/>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>

<xsl:template match="school">

Name:<b><xsl:value-of select="@name"/></b>

<!-- insert optional data here, i.e: "cool school!!" -->

<xsl:apply-templates select="teachers"/>
<xsl:apply-templates select="classes"/>

<xsl:variable name="class_num" select="count(class_type)" >
</xsl:variable>
Class Type:
<xsl:if test="$class_num=3">A</xsl:if>
<xsl:if test="$class_num=2">B</xsl:if>
<xsl:if test="$class_num=1">C</xsl:if>
</xsl:template>

<xsl:template match="teachers">
<br></br>
Teachers:<font style="font-size:13px; font-weight: bold;" color="#ff0000">
<xsl:value-of select="."/>
<br></br>
</font>
</xsl:template>

<xsl:template match="classes">
Classes:
<b>
<xsl:value-of select="."/>
</b>
<br></br>
</xsl:template>

</xsl:stylesheet>

thanks guys!
i really wanna learn how manipulate this stuff the right way!
[3200 byte] By [Bengi] at [2007-11-19 2:46:49]
# 1 Re: How to Show...
You can use the text() function to only get the text in the current node, and you can use normalize-space() to strip any leading and trailing whitespace from a text node. So to get a cleaner version of "cool school!!", in you school template, you could write something like.

<value-of select="normalize-space(text())"/>
khp at 2007-11-10 3:27:53 >
# 2 Re: How to Show...
thanks Khp!!

you'v really helped me to learn new stuff :) :thumb:
Bengi at 2007-11-10 3:28:53 >