I am trying to display XML-based data using an XSL. The following throws an
error on the transform statement. What am I doing wrong.
<cfxml variable="xmlString" >
<invoice date = "2003-08-15">
<line-item quantity = "2" upc = "ID234">
<description> catcher mit </description>
<price currency = "usd"> 250.53 </price>
</line-item>
<line-item quantity = "5" upc = "ID911">
<description> baseball bat
</description>
<price currency = "usd"> 38.22 </price>
</line-item>
<line-item quantity = "1" upc = "ID1890">
<description> catcher mask
</description>
<price currency = "usd"> 45.00 </price>
</line-item>
</invoice>
</cfxml>
<cfset xmlStyle = '
<?xml version = "1.0"?>
<xsl:stylesheet
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
version = "1.0">
<xsl:template match = "invoice">
<xsl:variable name = "nodes" select = "//product"/>
<html>
<head><title> XSL Demo </title></head>
<body>
<table align = "center" width = "75%" border = "4">
<caption align="top"> Your Invoice </caption>
<tr>
<th width="30%"> Description </th>
<th width="20%"> Quantity </th>
<th width="30%"> Price </th>
</tr>
<xsl:for-each select = "line-item">
<tr>
<td align = "center">
<xsl:value-of select = "description"/> </td>
<td align = "center">
<xsl:value-of select = "@quantity"/>
</td>
<td align = "center">
$<xsl:value-of select = "price"/>
</td>
</tr>
</xsl:for-each>
</table>
<br/><br/>
Your total is $
<xsl:call-template name = "getTotal">
<xsl:with-param name = "items" select = "line-item"/>
<xsl:with-param name = "total" select = "0"/>
</xsl:call-template>
</body>
</html>
</xsl:template>
<xsl:template name = "getTotal">
<xsl:param name = "items"/>
<xsl:param name = "total"/>
<xsl:choose>
<xsl:when test = "$items">
<xsl:variable name = "temp"
select = "$items[1]/price * $items[1]/@quantity"/>
<xsl:call-template name = "getTotal">
<xsl:with-param name = "items"
select = "$items[position() != 1]"/>
<xsl:with-param name = "total"
select = "$total + $temp"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select = "$total"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
' />
<cfoutput>#xmlTransform(xmlString, xmlStyle)#</cfoutput>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:218141
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54