• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Problem with .XSL not rendering .CSS correctly

Joined
Jul 27, 2006
Messages
50
My xsl document does not seem to render my style sheet correctly. This is how I declared the style sheet: (BTW I am using firefox)

<xsl:template match="/">

<html>​
<head><title> Gladiators of New </title>​
<link rel="stylesheet" type="text/css" href="style.css"/>​
</head>​
<body>​
Bla bla​
</body>​
</html>​
</xsl:template>


The following links show what happens. (These links are temporary)

XHTML with desired results:

http://cse.unl.edu/~tnichols/xcse464x/temp/tournaments.html

XSL with undesirable results:

http://cse.unl.edu/~tnichols/xcse464x/2/tournaments.xml



Is there another way to declare the style sheet so the xsl renders it correctly?
A hack fix would be to set the px height but this is somewhat undesirable for obvious reasons.

Any suggestions?


thanx


 
I saved a local copy of tournaments.xsl, tournaments.xml and style.css

Everything is working perfectly for what you have coded so far! (perhaps you have a more recent .xsl that you did not upload yet?)

http://cse.unl.edu/~tnichols/xcse464x/2/tnichols-schemas/tournaments.dtd does not exist - but that is not affecting the rendering of your xml document.

The specific tournament xml documents do not exist: tnichols-tournament1/tournament1.xml and tnichols-tournament2/tournament2.xml - Once you upload those, you will need to continue coding your XSLT to transform that data the way you would like it.

Does that make sense?

edit: Something just dawned on me. Are you referring to the background color? I see that it is rendering differently.
 
Ok, after looking at this some more, I think I see exactly what you are trying to do:

I see what you were trying to do in your xsl:

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

I'm assuming that what you were trying to do here was have the resulting .xml document be in the http://www.w3.org/1999/xhtml namespace?

If that was your intention, you would need to use the xml:namespace-alias element. ( http://www.w3schools.com/xsl/el_namespace-alias.asp )

I'll help write an example using the namespace-alias later tonight or tomorrow.



But in the meantime, the easiest fix for your .xml document not rendering the same as your XHTML document would be to edit your .xsl file:

Here is the offending code:
Code:
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns="http://www.w3.org/1999/xhtml" >

Change to:

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

And your stylesheet seems to display your .xml document correctly.
 
The biggest problem with only using Firefox to debug is that you never see what your xslt is actually generating!

Here's a freeware tool that I use all the time: http://saxon.sourceforge.net/ (get Saxon-B 8.9 for .NET - that's the freeware version)

(incidentally, I install this program to c:\utils\saxon and then add this directory to my path. Now I can use the transform tool wherever I am!)

Here is the command to render your document:

transform.exe -s tournaments.xml -o rendered.xml tournaments.xsl

Now, if I use your xml and xslt, it generates a horrendous looking document with most carriage returns mysteriously missing.

rendered.xml with existing xslt
Code:
<?xml version="1.0" encoding="UTF-8"?><html xmlns="http://www.w3.org/1999/xhtml"><head><title> Gladiators of New </title><link rel="stylesheet" type="text/css" href="style.css"/></head><body><h1>

			Gladiators of New
		</h1><table class="menuTable" border="0"><tr><td><a href="index.html">Main</a></td><td><a href="tournaments.xml">Tournaments</a></td><td><a href="contestants.xml">Contestants</a></td><td><a href="fame.xml">Hall of Fame</a></td><td><a href="rules.html">Rules</a></td></tr></table><table class="table1" border="1"><tr><th colspan="5">
					Scheduled Tournaments
				</th></tr><tr><th>
					Tournament
				</th><th>
					Date
				</th><th>
					Location
				</th><th>
					Roster
				</th><th>
					Status
				</th></tr><tr><td class="center"><a href="tnichols-tournament1/tournament1.xml" target="_blank">Tournament I</a></td><td class="center">January 2007</td><td class="center"><a href="tnichols-pics/colosseum.jpg" target="_blank">Roman Colosseum</a></td><td class="center">8</td><td class="center">Completed </td></tr><tr><td class="center"><a href="tnichols-tournament2/tournament2.xml" target="_blank">Tournament II</a></td><td class="center">February 2007</td><td class="center"><a href="tnichols-pics/colosseum.jpg" target="_blank">Roman Colosseum</a></td><td class="center">8</td><td class="center">Completed</td></tr></table></body></html>


Now if we remove that offending line (that I mentioned in the previous post) the output is MUCH nicer :)

rendered.xml with updated xslt
Code:
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title> Gladiators of New </title>
      <link rel="stylesheet" type="text/css" href="style.css">
   </head>
   <body>
      <h1>
         
         			Gladiators of New
         		
      </h1>
      <table class="menuTable" border="0">
         <tr>
            <td><a href="index.html">Main</a></td>
            <td><a href="tournaments.xml">Tournaments</a></td>
            <td><a href="contestants.xml">Contestants</a></td>
            <td><a href="fame.xml">Hall of Fame</a></td>
            <td><a href="rules.html">Rules</a></td>
         </tr>
      </table>
      <table class="table1" border="1">
         <tr>
            <th colspan="5">
               					Scheduled Tournaments
               				
            </th>
         </tr>
         <tr>
            <th>
               					Tournament
               				
            </th>
            <th>
               					Date
               				
            </th>
            <th>
               					Location
               				
            </th>
            <th>
               					Roster
               				
            </th>
            <th>
               					Status
               				
            </th>
         </tr>
         <tr>
            <td class="center"><a href="tnichols-tournament1/tournament1.xml" target="_blank">Tournament I</a></td>
            <td class="center">January 2007</td>
            <td class="center"><a href="tnichols-pics/colosseum.jpg" target="_blank">Roman Colosseum</a></td>
            <td class="center">8</td>
            <td class="center">Completed </td>
         </tr>
         <tr>
            <td class="center"><a href="tnichols-tournament2/tournament2.xml" target="_blank">Tournament II</a></td>
            <td class="center">February 2007</td>
            <td class="center"><a href="tnichols-pics/colosseum.jpg" target="_blank">Roman Colosseum</a></td>
            <td class="center">8</td>
            <td class="center">Completed</td>
         </tr>
      </table>
   </body>
</html>


And it renders correctly.
 
Wow, thank you for all the replies. I will go through them and see what I can do to the site tomorrow or this weekend. I really appreciate the input. I would do it now but I’ve been drinking a little bit. And coding with some drink in you is prolly not the best practices.

Just to clarify a bit (since I think I forgot to mention) I was talking about the background color.

Oh, awesome on the tool. I will install that tomorrow and check it out. I had a tool to look at the HTML but I couldn’t get it to work properly.

Thank you a ton
zz



 
Thank you for the help.

I was using examples out of books and from class to derive the header. I wasn&#8217;t really being graded on the way to looked this time around, it was really the use of xml, xslt, dtd and xmls. But I am semi-neurotic and like to have everything the way it really should be.

I fixed everything and my site looks much better.

Oh, this not only fixed my background, it also fixed all the problems I was having with my tables as well.

Thanks again

zz



 
Back
Top