Game Development Reference
In-Depth Information
<xsl:stylesheet version =
1.0
<xsl:template match="/a:COLLADA">
<html>
<body>
<h2>External references</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>id</th>
<th>url</th>
</tr>
<xsl:for-each select="a:library_images/a:image">
<tr>
<td><xsl:value-of select="@id"/></td>
<td><xsl:value-of select="a:init_from"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Listing 9.3.
An XSL template (program) to list all external image files.
It prints out the value of the element
init_from
using
xsl:value-of
'select='a:init_from"
as well as the value of the image parameter
id
using
xsl:value-of select="@id."
The HTML tags that format the page are simply inserted in the XLST script
when they need to appear.
Running this script on duck.dae returns the XHTML document shown in List-
ing 9.4.
<html xmlns:a="
http://www.collada.org/2005/11/COLLADASchema
">
<body>
<h2>External references</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>id</th>
<th>url</th>
</tr>
<tr>
<td>file2 </td>
<td>./duckCM.jpg</td>
</tr>
</table>
</body>
</html>
Listing 9.4.
An HTML page created by an XSL program.