Listing 1: xmlutilities.cfm
<!--- Listing 1: XMLIndent()
requires one argument of type XML
returns the resulting XML as text --->
<cffunction name="XMLIndent" returntype="string">
<cfargument name="xml" type="string" required="Yes">
<cfset xsl='<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xslt">
<xsl:output indent="yes" xalan:indent-amount="2"/>
<xsl:template match="/">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>'>
<cfset output=xmltransform(arguments.xml, xsl)>
<cfreturn output>
</cffunction>
Listing 2: mmresources.cfm
<!--- Listing 2 - Transforms from the Macromedia
DesDev Resource Feed to WDDX --->
<!DOCTYPE html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Macromedia Resources</title>
</head>
<body>
<cfinclude template="XMLUtilities.cfm">
<cfhttp
url="http://www.macromedia.com/desdev/
resources/macromedia_resources.xml"/>
<cffile action="read" variable="xslt"
file="#ExpandPath(Ô.')#\MMResources.xsl">
<cfset result=xmltransform(cfhttp.filecontent, xslt)>
<cfoutput>#result#</cfoutput>
</body>
</html>
Listing 3: mmresources.xsl
<?xml version="1.0" encoding="UTF-8"?>
<!-- Listing 3 : mmresources.xsl
A Stylesheet for turning the
Macromedia DesDev Resource Feed into HTML -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="macromedia_resources">
<h1 align="center">Macromedia Resources</h1>
<table border="1" width="90%" align="center">
<tr bgcolor="#99ffff"><th>Article</th><th>Author</th></tr>
<xsl:apply-templates select="resource[@type='Article']"/>
</table>
</xsl:template>
<xsl:template match="resource">
<tr>
<xsl:choose>
<xsl:when test="position() mod 2">
<xsl:attribute name="bgcolor">#ffffff</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="bgcolor">#99ff99</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<td width="60%">
<a href="{url}"><xsl:value-of select="title"/></a>
</td>
<td><xsl:value-of select="author"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
Listing 4: mmresources2wddx.xsl
<?xml version="1.0" encoding="UTF-8"?>
<!-- Listing 4: mmresources2wddx.xsl
A Stylesheet for turning the
Macromedia DesDev Resource Feed into WDDX -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="resourcetype">Article</xsl:variable>
<xsl:template match="macromedia_resources">
<wddxPacket version="1.0">
<header />
<data>
<array length="{count(resource[@type=$resourcetype])}">
<xsl:apply-templates select="resource[@type=$resourcetype]"/>
</array>
</data>
</wddxPacket>
</xsl:template>
<xsl:template match="resource">
<struct>
<var name="TITLE">
<string><xsl:value-of select="title"/></string>
</var>
<var name="AUTHOR">
<string><xsl:value-of select="author"/></string>
</var>
</struct>
</xsl:template>
</xsl:stylesheet>
Listing 5: mmresources2wddx.cfm
<!--- Listing 5 - Transforms from the Macromedia
DesDev Resource Feed to WDDX --->
<cfhttp
url="http://www.macromedia.com/desdev/
resources/macromedia_resources.xml"/>
<cffile action="read" variable="xslt"
file="#ExpandPath(Ô.')#\mmresources2wddx.xsl">
<cfset wddx=xmltransform(cfhttp.filecontent, xslt)>
<cfdump var="#wddx#">