xsl not transforming correctly

Water Cooler v2

Usenet Archive
Joined
Nov 22, 2004
Messages
91
Reaction score
0
I am an XSL newbie and this is my first XSL example. It does not render any rows in the table. It only shows the table header row with the column lables; no data rows. Please guide me.

XML FILE
<?xml version="1.0" encoding="ISO8859-1" ?>
<?xml-stylesheet type="text/xsl" href="booklist.xsl"?>
<BOOKLIST>
<BOOK>
<TITLE>Programming in the key of C#</TITLE>
<AUTHOR>Charles Petzold</AUTHOR>
<PUBLISHER>Microsoft Press</PUBLISHER>
</BOOK>

<BOOK>
<TITLE>Code: the hidden language of computer hardware and software</TITLE> <AUTHOR>Charles Petzold</AUTHOR> <PUBLISHER>Microsoft Press</PUBLISHER> </BOOK>

<BOOK>
<TITLE>Applied Microsoft .NET Framework Programming</TITLE> <AUTHOR>Jeffrey Richter</AUTHOR> <PUBLISHER>Microsoft Press</PUBLISHER> </BOOK>

<BOOK>
<TITLE>CDO and MAPI Programming in Visual Basic</TITLE> <AUTHOR>Dave Grundgieger</AUTHOR> <PUBLISHER>O'reilly</PUBLISHER> </BOOK>

<BOOK>
<TITLE>Moving from VB to VB.NET: concepts and strategies</TITLE> <AUTHOR>Dan Appleman</AUTHOR> <PUBLISHER>A-press</PUBLISHER> </BOOK> </BOOKLIST>

XSL FILE
<?xml version="1.0" encoding="ISO8859-1" ?>
<xsl:stylesheet xmlns:xsl="http://w3.org/TR/WD-xsl"> <xsl:template match="/"> <HTML> <BODY> <TABLE border="1" background-color="blue"> <TH> <TD>Title</TD> <TD>Author</TD> <TD>Publisher</TD> </TH>

<xsl:for-each select="BOOKLIST/BOOK">
<TR>
<TD><xsl:value-of select="TITLE"/></TD>
<TD><xsl:value-of select="AUTHOR"/></TD>
<TD><xsl:value-of select="PUBLISHER"/></TD>
</TR>
</xsl:for-each>
</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
 

Joe Fawcett

Usenet Archive
Joined
Apr 3, 2000
Messages
126
Reaction score
0
Water Cooler v2 said:
I am an XSL newbie and this is my first XSL example. It does not render any rows in the table. It only shows the table header row with the column lables; no data rows. Please guide me.

XML FILE
<?xml version="1.0" encoding="ISO8859-1" ?>
<?xml-stylesheet type="text/xsl" href="booklist.xsl"?>
<BOOKLIST>
<BOOK>
<TITLE>Programming in the key of C#</TITLE>
<AUTHOR>Charles Petzold</AUTHOR>
<PUBLISHER>Microsoft Press</PUBLISHER>
</BOOK>

<BOOK>
<TITLE>Code: the hidden language of computer hardware and software</TITLE> <AUTHOR>Charles Petzold</AUTHOR> <PUBLISHER>Microsoft Press</PUBLISHER> </BOOK>

<BOOK>
<TITLE>Applied Microsoft .NET Framework Programming</TITLE> <AUTHOR>Jeffrey Richter</AUTHOR> <PUBLISHER>Microsoft Press</PUBLISHER> </BOOK>

<BOOK>
<TITLE>CDO and MAPI Programming in Visual Basic</TITLE> <AUTHOR>Dave Grundgieger</AUTHOR> <PUBLISHER>O'reilly</PUBLISHER> </BOOK>

<BOOK>
<TITLE>Moving from VB to VB.NET: concepts and strategies</TITLE> <AUTHOR>Dan Appleman</AUTHOR> <PUBLISHER>A-press</PUBLISHER> </BOOK> </BOOKLIST>

XSL FILE
<?xml version="1.0" encoding="ISO8859-1" ?>
<xsl:stylesheet xmlns:xsl="http://w3.org/TR/WD-xsl"> <xsl:template match="/"> <HTML> <BODY> <TABLE border="1" background-color="blue"> <TH> <TD>Title</TD> <TD>Author</TD> <TD>Publisher</TD> </TH>

<xsl:for-each select="BOOKLIST/BOOK">
<TR>
<TD><xsl:value-of select="TITLE"/></TD>
<TD><xsl:value-of select="AUTHOR"/></TD>
<TD><xsl:value-of select="PUBLISHER"/></TD>
</TR>
</xsl:for-each>
</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>

Dear Cooler

You are trying to use an outdated and obsolete pre-cursor to XSLT as shown in the namespace "http://w3.org/TR/WD-xsl", (the WD stands for working draft, I believe). This is only supported by early versions of MSXML and you will find little or no documentation and support for it. Change to the newer namespace of http://www.w3.org/1999/XSL/Transform. You will find many examples of creating tables in HTML from raw XML online or you can buy one of Michael Kay's excellent tomes. I believe the example you have should work if you change the namespace as outlined above, if you are still struggling let us know.
 

Andy Dingley

Usenet Archive
Joined
Feb 23, 2000
Messages
3,303
Reaction score
0
Water said:
I am an XSL newbie

Newbie? I'm increasingly beginning to think you're an out-an-out Troll.

Learn to web search. Get some decent references that are less than 5 years old. Stop asking the most blindingly stupid questions, on any topic, that it's just about possible to think up.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,244
Members
248,133
Latest member
DujonT

Latest Threads

Top