[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Testing Transformation Filter - does this XML/XSLT work?


Subject: Re: [xsl] Testing Transformation Filter - does this XML/XSLT work?
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Fri, 28 Jan 2005 08:15:07 -0800

Are you sure the param 'code' is being sent? In your html body you could do something like:

**<xsl:value-of select="$code"/>**

On another note, you are trying to output XHTML, but your output method is HTML -- it should be XML. Further the rendered page will not validate (ugghh font tags...).

General advice: use the XSL to output bare bones HTML. Put classes/ids on the elements with special styling needs and put the styling in an external CSS.

best,
-Rob


Julian Voelcker wrote:
I am trying to test some ASP.Net transformation code that I have, but being a novice have no idea if the XML/XLST combination is correct.

Here are the files that I am using - I get the page rendered, but not any of the courses -any ideas.

XML:
<?xml version="1.0" encoding="UTF-8" ?>
<root>
 <courses>
  <state name="Arizona" code="AZ">
   <course id="AZ-1" name="Pinetop Lakes Golf &amp; CC" />
   <course id="AZ-2" name="Ocotillo" />
   <course id="AZ-3" name="White Mountain CC" />
  </state>
  <state name="California" code="CA">
   <course id="CA-1" name="Pebble Beach" />
   <course id="CA-2" name="Spy Glass" />
   <course id="CA-3" name="Los Angeles CC" />
  </state>
  <state name="Florida" code="FL">
   <course id="FL-1" name="TPC Sawgrass" />
   <course id="FL-2" name="Disney" />
  </state>
 </courses>
</root>

XSLT:
<?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" version="1.0" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" indent="yes"/>
 <xsl:param name="code"/>
 <xsl:template match="/">
  <xsl:apply-templates/>
 </xsl:template>
 <xsl:template match="root">
  <html lang="eng" xml:lang="eng" xmlns="http://www.w3.org/1999/xhtml">
   <head>
    <title>Book a Tee Time</title>
    <link rel="stylesheet" type="text/css" href="/TeeTimes/style/style.css"/>
    <script language="javascript" src="/TeeTimes/scripts/scripts.js" type="text/javascript"/>
   </head>
   <body bgcolor="#FFFFFF">
    <table border="0" width="640" class="borders" cellpadding="3" cellspacing="0" bgcolor="#e6e6cc">
     <tr valign="top" align="left" bgcolor="#007900">
      <td colspan="2">
       <font face="Arial, Helvetica, sans-serif" size="5" color="#e6e6cc">
        <b>
         <xsl:value-of select="//state[@code=$code]/@name"/>Courses:</b>
       </font>
      </td>
     </tr>
     <tr>
      <td width="10%">
       <img src="/TeeTimes/images/golfer.jpg" alt=" "/>
      </td>
      <td valign="top" align="center">
       <xsl:apply-templates/>
      </td>
     </tr>
    </table>
   </body>
  </html>
 </xsl:template>
 <xsl:template match="courses">
  <xsl:apply-templates select="state[@code = $code]"/>
 </xsl:template>
 <xsl:template match="state">
  <table border="0" width="95%" cellpadding="5">
   <tr>
    <xsl:for-each select="course">
     <xsl:sort select="@code" order="ascending"/>
     <a href="/TeeTimes/bookTime.aspx?course={@id}" class="course">
      <xsl:value-of select="@name"/>
     </a>
     <br/>
    </xsl:for-each>
   </tr>
  </table>
 </xsl:template>
</xsl:stylesheet>


Any pointers would be appreciated.


Current Thread
Keywords