Jump to content
Sign in to follow this  
steve_marjoribanks

Stylesheet problem

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>

Share this post


Link to post
Share on other sites

Also, you may want to make your html tags all lower-case, which is the proper way for current and future versions of (x)html.

Share this post


Link to post
Share on other sites
Also, you may want to make your html tags all lower-case, which is the proper way for current and future versions of (x)html.
This is only true for xhtml. Current and future versions of HTML allow a mix of upper and lower case tags see here.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...