1. The Rule file
-------------- rule.xml -------------------------------
<rules>
<rule id="J" color="orange" face="verdana"/>
<rule id="K" color="blue" face="comic sans ms"/>
<rule id="P" color="firebrick" face="courier new" />
<rule id="W" color="green" mask="****" face="arial black"/>
</rules>
2. The Data file
-------------- data.xml -------------------------------
<?xml-stylesheet type="text/xsl" href="read.xsl"?>
<products>
<product id="K1">
<name>Corn Flakes</name>
<price>12.90</price>
</product>
<product id="J1">
<name>Orange Jiuce</name>
<price>120.95</price>
</product>
<product id="J5">
<name>Banana Jiuce</name>
<price>750.95</price>
</product>
<product id="P6">
<name>Yam Pie</name>
<price>10.25</price>
</product>
<product id="W3">
<name>Smoked Herbs</name>
<price>320.00</price>
</product>
</products>
3. The Read file
-------------- read.xsl -------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="
version="1.0">
<xsl:variable name="rules" select="document('rule.xml')/rules" />
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="products">
<ul>
<xsl:apply-templates />
</ul>
</xsl:template>
<xsl:template match="product">
<xsl:variable name="ruleId" select="substring(@id,1,1)" />
<xsl:variable name="rule" select="$rules/rule[@id=$ruleId]" />
<b>
<li style="color:{$rule/@color};font-family:{$rule/@face};">
<xsl:value-of select="name" />
<xsl:text> </xsl:text>
<i>
<xsl:choose>
<xsl:when test="$rule/@mask">
<xsl:value-of select="$rule/@mask" />
</xsl:when>
<xsl

therwise>
<xsl:value-of select="price" />
</xsl

therwise>
</xsl:choose>
</i>
</li>
</b>
</xsl:template>
</xsl:stylesheet>