XSL and XSLT Page 43
March 22, 2002
The next long block of code builds the table that displays the
contents of the XML file. Using the for-each loop we cycle
through each instance of Travelpackage. When the processor
encounters the <xsl:value-of select"Elementname"
/> element, it enters the value of the element. In this way
the xsl:value-of element acts like a variable:
<xsl:for-each select="Travelpackage">
<tr>
<td>
<xsl:text>Country_name</xsl:text>
</td>
<td>
<xsl:value-of select="Country_name" />
</td>
</tr>
<tr>
<td>
<xsl:text>City</xsl:text>
</td>
<td>
<xsl:value-of select="City" />
</td>
</tr>
<tr>
<td>
<xsl:text>Resort</xsl:text>
</td>
<td>
<xsl:value-of select="Resort" />
</td>
</tr>
<tr>
<td>
<xsl:text>Resort_rating</xsl:text>
</td>
<td>
<xsl:value-of select="Resort_rating" />
</td>
</tr>
<tr>
<td>
<xsl:text>Resort_typeofholiday</xsl:text>
</td>
<td>
<xsl:value-of select="Resort_watersports" />
</td>
</tr>
<tr>
<td>
<xsl:text>Resort_watersports</xsl:text>
</td>
<td>
<xsl:value-of select="Resort_watersports" />
</td>
</tr>
<tr>
<td>
<xsl:text>Resort_meals</xsl:text>
</td>
<td>
<xsl:value-of select="Resort_meals" />
</td>
</tr>
<tr>
<td>
<xsl:text>Resort_drinks</xsl:text>
</td>
<td>
<xsl:value-of select="Resort_drinks" />
</td>
</tr>
<tr>
<td>
<xsl:text>Package_dateofdep</xsl:text>
</td>
<td>
<xsl:value-of select="*/Package_dateofdep" />
</td>
</tr>
<tr>
<td>
<xsl:text>Package_price</xsl:text>
</td>
<td>
<xsl:value-of select="*/Package_price" />
</td>
</tr>
<tr>
<td colspan="2"><hr /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XSL and XSLT Page 42
Professional PHP4 Programming
XSL and XSLT Page 44
|