this is my code::
<!--school.xml-->
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="school.xsl"?>
<UCSC>
<student>
<name>Isuru ilangakoon</name>
<age>21</age>
<contct_no>0714234672</contct_no>
<degree>computer science</degree>
<school>DVharmapala college</school>
</student>

<student>
<name>randika malinga</name>
<age>22</age>
<contact_no>0713567134</contact_no>
<degree>computer science</degree>
<school>Nalanda college</school>
</student>

<student>
<name>vinod kawinda</name>
<age>22</age>
<contct_no>0783451024</contct_no>
<degree>computer science</degree>
<school>maliyadewa college</school>
</student>

<student>
<name>Inshaf mahatt</name>
<age>21</age>
<contct_no>0777234151</contct_no>
<degree>ICT</degree>
<school>D.S.Senanayaka college</school>
</student>

<student>
<name>Dilum lokuge</name>
<age>21</age>
<contct_no>0724123673</contct_no>
<degree>computer science</degree>
<school>mahanama college</school>
</student>

<student>
<name>Yassari kasun</name>
<age>22</age>
<contct_no>0783482493</contct_no>
<degree>computer science</degree>
<school>Thakshila college</school>
</student>

<student>
<name>Akila ravihansa</name>
<age>21</age>
<contct_no>0777314734</contct_no>
<degree>computer science</degree>
<school>Ananda college</school>
</student>

<student>
<name>Nuwan chaturanga</name>
<age>20</age>
<contct_no>0774853673</contct_no>
<degree>computer science</degree>
<school>Royal college</school>
</student>

<student>
<name>Shazan buka</name>
<age>23</age>
<contct_no>0776235924</contct_no>
<degree>computer science</degree>
<school>thurstan college</school>
</student>

<student>
<name>Dhanushika nawinna</name>
<age>21</age>
<contct_no>0714324672</contct_no>
<degree>BIT</degree>
<school>Goodshepherd convent</school>
</student>
</UCSC>

And this is my school.xsl file

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://WWW.W3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<body>
<h2> UCSC Informations</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Name</th>
<th>Age</th>
<th>Contact No</th>
<th>Degree</th>
<th>School</th>
</tr>
<xsl:for-each select="UCSC/student">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="age"/></td>
<td><xsl:value-of select="contact_no"/></td>
<td><xsl:value-of select="degree"/></td>
<td><xsl:value-of select="school"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>

</xsl:stylesheet>

it always get this error..
"Error loading stylesheet: Parsing an XSLT stylesheet failed." can any one find the error!!

Hi,

you have 2 remember two things to solve this issue.,
1. xml declaraion is optional in xml document. however, if you give the xml declaraion. it should be occurs immediate within the xml document. <?xml version="1.0"?>
2. xsl namespace should be [http://www.w3.org/1999/XSL/Transform] case sensitive.

hence try this codes

1. xml doc

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="school.xsl"?>
<UCSC>
<student>
<name>Isuru ilangakoon</name>
<age>21</age>
<contct_no>0714234672</contct_no>
<degree>computer science</degree>
<school>DVharmapala college</school>
</student>

<student>
<name>randika malinga</name>
<age>22</age>
<contact_no>0713567134</contact_no>
<degree>computer science</degree>
<school>Nalanda college</school>
</student>

<student>
<name>vinod kawinda</name>
<age>22</age>
<contct_no>0783451024</contct_no>
<degree>computer science</degree>
<school>maliyadewa college</school>
</student>

<student>
<name>Inshaf mahatt</name>
<age>21</age>
<contct_no>0777234151</contct_no>
<degree>ICT</degree>
<school>D.S.Senanayaka college</school>
</student>

<student>
<name>Dilum lokuge</name>
<age>21</age>
<contct_no>0724123673</contct_no>
<degree>computer science</degree>
<school>mahanama college</school>
</student>

<student>
<name>Yassari kasun</name>
<age>22</age>
<contct_no>0783482493</contct_no>
<degree>computer science</degree>
<school>Thakshila college</school>
</student>

<student>
<name>Akila ravihansa</name>
<age>21</age>
<contct_no>0777314734</contct_no>
<degree>computer science</degree>
<school>Ananda college</school>
</student>

<student>
<name>Nuwan chaturanga</name>
<age>20</age>
<contct_no>0774853673</contct_no>
<degree>computer science</degree>
<school>Royal college</school>
</student>

<student>
<name>Shazan buka</name>
<age>23</age>
<contct_no>0776235924</contct_no>
<degree>computer science</degree>
<school>thurstan college</school>
</student>

<student>
<name>Dhanushika nawinna</name>
<age>21</age>
<contct_no>0714324672</contct_no>
<degree>BIT</degree>
<school>Goodshepherd convent</school>
</student>
</UCSC>

2. xsl doc

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2> UCSC Informations</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Name</th>
<th>Age</th>
<th>Contact No</th>
<th>Degree</th>
<th>School</th>
</tr>
<xsl:for-each select="UCSC/student">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="age"/></td>
<td><xsl:value-of select="contact_no"/></td>
<td><xsl:value-of select="degree"/></td>
<td><xsl:value-of select="school"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Thanks and Regards,
yuvanbala

without For-each

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

	<xsl:template match="/">
		<html>
			<title>Students</title>
			<style type="text/css">
table
{
width:100%;
/*background-color:#9acd32;*/
/*border-collapse:collapse;*/

}
tr
{
background-color:#9acd32;
/*border-collapse:collapse;*/

}
table,th,td
{
border: 2px solid black;
margin:2px;
}
td
{
width:20%;
background-color:#e6e6e6;
padding:30px;
text-align:center;
}</style>

			<xsl:apply-templates select="UCSC"/>
		</html>
	</xsl:template>




	<xsl:template match="UCSC">
		<h2>UCSC Informations</h2>
		<table border="1">
			<tr>
				<th>Name</th>
				<th>Age</th>
				<th>Contact No</th>
				<th>Degree</th>
				<th>School</th>
			</tr>
			<xsl:apply-templates select="student"/>
		</table>
	</xsl:template>
	<xsl:template match="student">
		<tr>
			<td>
				<xsl:value-of select="name"/>
			</td>
			<td>
				<xsl:value-of select="age"/>
			</td>
			<td>
				<xsl:value-of select="contct_no"/>
			</td>
			<td>
				<xsl:value-of select="degree"/>
			</td>
			<td>
				<xsl:value-of select="school"/>
			</td>
		</tr>
	</xsl:template>
</xsl:stylesheet>

result html

<html>
  <title>Students</title>
  <style type="text/css">table
{
width:100%;
/*background-color:#9acd32;*/
/*border-collapse:collapse;*/

}
tr
{
background-color:#9acd32;
/*border-collapse:collapse;*/

}
table,th,td
{
border: 2px solid black;
margin:2px;
}
td
{
width:20%;
background-color:#e6e6e6;
padding:30px;
text-align:center;
}
  </style>
  <h2>UCSC Informations</h2>
  <table border="1">
    <tr>
      <th>Name</th>
      <th>Age</th>
      <th>Contact No</th>
      <th>Degree</th>
      <th>School</th>
    </tr>
    <tr>
      <td>Isuru ilangakoon</td>
      <td>21</td>
      <td>0714234672</td>
      <td>computer science</td>
      <td>DVharmapala college</td>
    </tr>
    <tr>
      <td>randika malinga</td>
      <td>22</td>
      <td></td>
      <td>computer science</td>
      <td>Nalanda college</td>
    </tr>
    <tr>
      <td>vinod kawinda</td>
      <td>22</td>
      <td>0783451024</td>
      <td>computer science</td>
      <td>maliyadewa college</td>
    </tr>
    <tr>
      <td>Inshaf mahatt</td>
      <td>21</td>
      <td>0777234151</td>
      <td>ICT</td>
      <td>D.S.Senanayaka college</td>
    </tr>
    <tr>
      <td>Dilum lokuge</td>
      <td>21</td>
      <td>0724123673</td>
      <td>computer science</td>
      <td>mahanama college</td>
    </tr>
    <tr>
      <td>Yassari kasun</td>
      <td>22</td>
      <td>0783482493</td>
      <td>computer science</td>
      <td>Thakshila college</td>
    </tr>
    <tr>
      <td>Akila ravihansa</td>
      <td>21</td>
      <td>0777314734</td>
      <td>computer science</td>
      <td>Ananda college</td>
    </tr>
    <tr>
      <td>Nuwan chaturanga</td>
      <td>20</td>
      <td>0774853673</td>
      <td>computer science</td>
      <td>Royal college</td>
    </tr>
    <tr>
      <td>Shazan buka</td>
      <td>23</td>
      <td>0776235924</td>
      <td>computer science</td>
      <td>thurstan college</td>
    </tr>
    <tr>
      <td>Dhanushika nawinna</td>
      <td>21</td>
      <td>0714324672</td>
      <td>BIT</td>
      <td>Goodshepherd convent</td>
    </tr>
  </table>
</html>

Edited 5 Years Ago by xml_looser: n/a

DEAR ADMINISTRATOR; CAN YOU PLEASE REMOVE ALL OF THOSE PERSONAL NAMES FROM THIS POST?

ALL OF THOSE ARE REAL NAMES AND SOME STUPID PUT THOSE HERE.. SO NOW THOSE ARE LISTING ON GOOGLE SERCH.. PLEASE ROMOVE THEM..

This question has already been answered. Start a new discussion instead.