Jump to content

Stylesheet problem


steve_marjoribanks

Recommended Posts

Hi everyone, i'm hoping you can help me with a small code problem. I'm new to both HTML and XML and i've written just a very small .xml file to practice. I've also created an .xsl stylesheet which should display the data in a simple table in HTML. However when i open the file address.xml in internet explorer, the data has been sucessfully extracted from the XML file but it is just displayed as a long string of text not in the table as the stylesheet says. Basically, the HTML part isnt working for some reason. Hope you can help! Thanks :)Address.xml

 <?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="Address.xsl" ?><AddressBook xmlns="http://tempuri.org/Address.xsd"       schemaLocation="Address.xsd">    <Person>     <FirstName>Stephen</FirstName>        <Surname>Marjoribanks</Surname>        <University>Durham</University>        <College>Trevelyan</College>    </Person>    <Person>    <FirstName>Joe</FirstName>    <Surname>Bloggs</Surname>    <University>Leeds</University>    <College />  </Person></AddressBook>

Address.xsl

<?xml version="1.0" encoding="UTF-8" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">		<xsl:output method="html"/>  	<xsl:template match="/AddressBook">  <HTML> 	 <HEAD>    <TITLE>Address Book</TITLE> 	 </HEAD> 	 <BODY>    <H1>Address Book</H1><br/>    <HR/>    <TABLE BORDER="1">   	 <TD>First Name</TD>   	 <TD>Surname</TD>   	 <TD>University</TD>   	 <TD>College</TD>   	 <xsl:apply-templates/>    </TABLE> 	 </BODY>   </HTML>	</xsl:template>  		<xsl:template match="Person">  <TR> 	 <TD>    <xsl:value-of select="FirstName" /> 	 </TD> 	 <TD>    <xsl:value-of select="Surname" /> 	 </TD> 	 <TD>    <xsl:value-of select="University" /> 	 </TD> 	 <TD>    <xsl:value-of select="College" /> 	 </TD>  </TR>		</xsl:template>  </xsl:stylesheet>

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...