XML Page 7 Documentation
(This file is called "XMLPage7documentation.html".)

XSLT stylesheet document
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes"/> <xsl:variable name="cusCount" select="count(customers/customer)"/> <xsl:variable name="ordCount" select="count(customers/customer/orders/order)"/> <xsl:variable name="avgCount" select="$ordCount div $cusCount"/> <xsl:template match="customers"> <HTML> <H1>Average Numbers of Orders</H1> <TABLE border="1"> <TH>Number of Customers</TH> <TH>Number of Orders</TH> <TH>Average Number of Orders</TH> <TR> <TD class="number"><xsl:value-of select="$cusCount"/></TD> <TD class="number"><xsl:value-of select="$ordCount"/></TD> <TD class="number"><xsl:value-of select="format-number($avgCount,'#.##')"/></TD> </TR> </TABLE> <BR/><BR/><BR/> <H1>Customers Who Have Placed More Than Average No. of Orders </H1> <TABLE border="1"> <TH>Cust No.</TH> <TH>Name</TH> <TH>Number of Orders</TH> <TH>% of Total Orders</TH> <xsl:apply-templates select="customer[count(orders/order)>$avgCount]"> <xsl:sort select="count(orders/order) div $ordCount" order="descending"/> </xsl:apply-templates> </TABLE> </HTML> </xsl:template> <xsl:template match="customer"> <xsl:variable name="cusOrder" select="count(orders/order)"/> <TR> <TD><xsl:value-of select="@cno"/></TD> <TD><xsl:value-of select="name"/></TD> <TD class="number"><xsl:value-of select="$cusOrder"/></TD> <TD class="number"><xsl:value-of select="format-number($cusOrder div $ordCount * 100,'#,###.##')"/>%</TD> </TR> </xsl:template> <xsl:template match="*|@*"> <TD><xsl:value-of select="."/></TD> </xsl:template> </xsl:stylesheet>

The XML document
<?xml version="1.0"?> <?xml-stylesheet href="number7.xsl" type="text/xsl"?> <customers xsi:noNamespaceSchemaLocation="customers.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <customer cno="C111" corporate="false"> <name> <givenName>James</givenName> <familyName>Hird</familyName> </name> <address> <street>12 Raleigh Rd</street> <suburb>North Melbourne</suburb> <state>VIC</state> <postcode>3611</postcode> </address> <contacts> <home>(03) 9903-3401</home> <office>(03) 9903-3401</office> <mobile primary="true">04111222333</mobile> </contacts> </customer> <customer cno="C222" corporate="true"> <name> <companyName>Essendon Football Club</companyName> </name> <address> <street>10 Bomber Ave</street> <suburb>Windy Hill</suburb> <state>VIC</state> <postcode>3666</postcode> </address> <contacts> <name>Ray Horsburgh</name> <office primary="true">(03) 9111-9999</office> <mobile>04111222444</mobile> </contacts> <orders> <order no="O112"> <orderDate>2007-06-21</orderDate> <orderLine> <itemNo>I001</itemNo> <description>Orange Juice</description> <quantity>100</quantity> <unitPrice>1.50</unitPrice> <discount>2</discount> </orderLine> <orderLine> <itemNo>I002</itemNo> <description>Victoria Bitter</description> <quantity>200</quantity> <unitPrice>3</unitPrice> <discount>5</discount> </orderLine> </order> <order no="O121"> <orderDate>2006-01-20</orderDate> <orderLine> <itemNo>I001</itemNo> <description>Coke</description> <quantity>25</quantity> <unitPrice>1.20</unitPrice> <discount>0</discount> </orderLine> <orderLine> <itemNo>I002</itemNo> <description>Vegetarian Sandwich</description> <quantity>200</quantity> <unitPrice>2</unitPrice> <discount>5</discount> </orderLine> </order> <order no="O111"> <orderDate>2007-04-12</orderDate> <orderLine> <itemNo>I001</itemNo> <description>Sausage Roll</description> <quantity>100</quantity> <unitPrice>1</unitPrice> <discount>0</discount> </orderLine> <orderLine> <itemNo>I002</itemNo> <description>Meat Pies</description> <quantity>100</quantity> <unitPrice>2</unitPrice> <discount>10</discount> </orderLine> </order> </orders> </customer> <customer cno="C333" corporate="false"> <name> <givenName>Kevin</givenName> <familyName>Sheedy</familyName> </name> <address> <street>10 High St</street> <suburb>Essendon</suburb> <state>VIC</state> <postcode>3622</postcode> </address> <contacts> <home>(03) 9111-3333</home> <office>(03) 9111-9999</office> <mobile primary="true">04111222444</mobile> </contacts> <orders> <order no="O113"> <orderDate>2006-01-21</orderDate> <orderLine> <itemNo>I001</itemNo> <description>Sausage Roll</description> <quantity>1500</quantity> <unitPrice>1</unitPrice> <discount>20</discount> </orderLine> </order> <order no="O114"> <orderDate>2007-07-10</orderDate> <orderLine> <itemNo>I002</itemNo> <description>Meat Pies</description> <quantity>2000</quantity> <unitPrice>2</unitPrice> <discount>20</discount> </orderLine> <orderLine> <itemNo>I003</itemNo> <description>Orange Juice</description> <quantity>1000</quantity> <unitPrice>1.50</unitPrice> <discount>5</discount> </orderLine> </order> <order no="O122"> <orderDate>2007-01-01</orderDate> <orderLine> <itemNo>I001</itemNo> <description>Red Wine</description> <quantity>1500</quantity> <unitPrice>15</unitPrice> <discount>20</discount> </orderLine> </order> <order no="O115"> <orderDate>2007-07-11</orderDate> <orderLine> <itemNo>I001</itemNo> <description>Victoria Bitter</description> <quantity>2000</quantity> <unitPrice>3</unitPrice> <discount>10</discount> </orderLine> <orderLine> <itemNo>I002</itemNo> <description>Red Wine</description> <quantity>200</quantity> <unitPrice>15</unitPrice> <discount>2</discount> </orderLine> <orderLine> <itemNo>I003</itemNo> <description>Tomato and Ham Sandwich</description> <quantity>500</quantity> <unitPrice>2</unitPrice> <discount>5</discount> </orderLine> <orderLine> <itemNo>I004</itemNo> <description>Vegetarian Sandwich</description> <quantity>200</quantity> <unitPrice>2</unitPrice> <discount>0</discount> </orderLine> <orderLine> <itemNo>I005</itemNo> <description>Salmon Sandwich</description> <quantity>500</quantity> <unitPrice>3</unitPrice> <discount>0</discount> </orderLine> <orderLine> <itemNo>I006</itemNo> <description>Springroll</description> <quantity>1000</quantity> <unitPrice>0.5</unitPrice> <discount>0</discount> </orderLine> <orderLine> <itemNo>I007</itemNo> <description>White Wine</description> <quantity>500</quantity> <unitPrice>12</unitPrice> <discount>5</discount> </orderLine> </order> </orders> </customer> <customer cno="C444" corporate="false"> <name> <givenName>John</givenName> <familyName>Worsfold</familyName> </name> <address> <street>23 Bayview Ave</street> <suburb>South Perth</suburb> <state>WA</state> <postcode>6200</postcode> </address> <contacts> <home>(06) 6222-3333</home> <office>(06) 6222-9999</office> <mobile primary="true">04111222555</mobile> </contacts> <orders> <order no="O116"> <orderDate>2007-12-12</orderDate> <orderLine> <itemNo>I001</itemNo> <description>Orange Juice</description> <quantity>30</quantity> <unitPrice>1.50</unitPrice> <discount>0</discount> </orderLine> <orderLine> <itemNo>I002</itemNo> <description>Red Wine</description> <quantity>5</quantity> <unitPrice>15</unitPrice> <discount>0</discount> </orderLine> <orderLine> <itemNo>I003</itemNo> <description>Tomato and Ham Sandwich</description> <quantity>30</quantity> <unitPrice>2</unitPrice> <discount>0</discount> </orderLine> </order> <order no="O117"> <orderDate>2007-06-16</orderDate> <orderLine> <itemNo>I001</itemNo> <description>Tomato and Ham Sandwich</description> <quantity>30</quantity> <unitPrice>2</unitPrice> <discount>0</discount> </orderLine> </order> <order no="O123"> <orderDate>2007-06-17</orderDate> <orderLine> <itemNo>I001</itemNo> <description>Tomato and Ham Sandwich</description> <quantity>30</quantity> <unitPrice>2</unitPrice> <discount>0</discount> </orderLine> </order> </orders> </customer> <customer cno="C555" corporate="false"> <name> <givenName>Ben</givenName> <familyName>Cousins</familyName> </name> <address> <street>23 Long Ave</street> <suburb>West Perth</suburb> <state>WA</state> <postcode>6500</postcode> </address> <contacts> <home>(06) 6222-4444</home> <office>(06) 6222-9999</office> <mobile primary="true">04111222666</mobile> </contacts> <orders> <order no="O120"> <orderDate>2007-05-05</orderDate> <orderLine> <itemNo>I001</itemNo> <description>Sausage Roll</description> <quantity>15</quantity> <unitPrice>1</unitPrice> <discount>0</discount> </orderLine> </order> </orders> </customer> <customer cno="C666" corporate="true"> <name> <companyName>West Coast Football Club</companyName> </name> <address> <street>1 Eagle Dr</street> <suburb>Subiaco</suburb> <state>WA</state> <postcode>6666</postcode> </address> <contacts> <name>Dalton Gooding</name> <office primary="true">(06) 6222-9999</office> <mobile>04111222555</mobile> </contacts> <orders> <order no="O118"> <orderDate>2007-04-12</orderDate> <orderLine> <itemNo>I001</itemNo> <description>Orange Juice</description> <quantity>1000</quantity> <unitPrice>1.50</unitPrice> <discount>5</discount> </orderLine> <orderLine> <itemNo>I002</itemNo> <description>Tomato and Ham Sandwich</description> <quantity>500</quantity> <unitPrice>2</unitPrice> <discount>5</discount> </orderLine> <orderLine> <itemNo>I003</itemNo> <description>Vegetarian Sandwich</description> <quantity>200</quantity> <unitPrice>2</unitPrice> <discount>0</discount> </orderLine> <orderLine> <itemNo>I004</itemNo> <description>Salmon Sandwich</description> <quantity>500</quantity> <unitPrice>3</unitPrice> <discount>0</discount> </orderLine> <orderLine> <itemNo>I005</itemNo> <description>Springroll</description> <quantity>1000</quantity> <unitPrice>0.5</unitPrice> <discount>0</discount> </orderLine> <orderLine> <itemNo>I006</itemNo> <description>Rice Paper Roll</description> <quantity>1000</quantity> <unitPrice>1.5</unitPrice> <discount>2</discount> </orderLine> <orderLine> <itemNo>I007</itemNo> <description>BBQ Chicken Wing</description> <quantity>1500</quantity> <unitPrice>0.75</unitPrice> <discount>2</discount> </orderLine> </order> <order no="O119"> <orderDate>2007-07-01</orderDate> <orderLine> <itemNo>I001</itemNo> <description>Coke</description> <quantity>500</quantity> <unitPrice>1.2</unitPrice> <discount>0</discount> </orderLine> <orderLine> <itemNo>I002</itemNo> <description>Lemonade</description> <quantity>500</quantity> <unitPrice>1.5</unitPrice> <discount>0</discount> </orderLine> </order> </orders> </customer> </customers>

The HTML document
<H1>Average Numbers of Orders</H1> <TABLE border="1" cellspacing="1" cellpadding="5"> <TH>Number of Customers</TH> <TH>Number of Orders</TH> <TH>Average Number of Orders</TH> <TR> <TD class="number">6</TD> <TD class="number">13</TD> <TD class="number">2.17</TD> </TR> </TABLE> <BR> <BR> <BR> <H1>Customers Who Have Placed More Than Average No. of Orders </H1> <TABLE border="1" cellspacing="1" cellpadding="5"> <TH>Cust No.</TH> <TH>Name</TH> <TH>Number of Orders</TH> <TH>% of Total Orders</TH> <TR> <TD>C333</TD> <TD> Kevin Sheedy </TD> <TD class="number">4</TD> <TD class="number">30.77%</TD> </TR> <TR> <TD>C222</TD> <TD> Essendon Football Club </TD> <TD class="number">3</TD> <TD class="number">23.08%</TD> </TR> <TR> <TD>C444</TD> <TD> John Worsfold </TD> <TD class="number">3</TD> <TD class="number">23.08%</TD> </TR> </TABLE>
XMLfile.jpg 200x30

XSLTfile.jpg 200x30