Created
January 16, 2013 22:06
-
-
Save pjmagee/4551390 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version='1.0' ?> | |
| <xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
| <xsl:output method="html" version="4.0" /> | |
| <xsl:template match="/"> | |
| <html> | |
| <head> | |
| <title>Customers Information</title> | |
| </head> | |
| <body> | |
| <h1>Customers</h1> | |
| <table border="1"> | |
| <tr> | |
| <th><b>ID</b></th> | |
| <th><b>Name</b></th> | |
| <th><b>Address</b></th> | |
| <th><b>Orders</b></th> | |
| </tr> | |
| <xsl:apply-templates/> | |
| </table> | |
| </body> | |
| </html> | |
| </xsl:template> | |
| <xsl:template match="customers"> | |
| <xsl:apply-templates select="customer"> | |
| <!-- I DID THE 2.6 ORDER BY SURNAME --> | |
| <xsl:sort select="customer/@last" data-type="text" order="descending" /> <!-- descending | ascending --> | |
| </xsl:apply-templates> | |
| </xsl:template> | |
| <xsl:template match="customer"> | |
| <xsl:for-each select="."> | |
| <tr> | |
| <td style="text-align: center;"><!-- ID --> | |
| <xsl:value-of select="name/@custID" /> | |
| </td> | |
| <td style="text-align: center;"><!-- NAME --> | |
| <xsl:value-of select="name/@first"/> | |
| <xsl:text> </xsl:text> | |
| <xsl:value-of select="name/@last" /> | |
| </td> | |
| <td style="text-align: center;"><!-- ADDRESS --> | |
| <xsl:value-of select="address/city"/>, | |
| <xsl:value-of select="address/post_code/@code"/> | |
| </td> | |
| <td> <!-- ORDERS --> | |
| <table border="1"> | |
| <tr> | |
| <th>Quantity</th> | |
| <th>Item</th> | |
| <th>Date Ordered</th> | |
| </tr> | |
| <xsl:for-each select="order/product"> | |
| <tr> | |
| <td style="text-align: center;"> | |
| <xsl:choose> | |
| <xsl:when test="@quantity != ''"> | |
| <xsl:value-of select="@quantity"/> x | |
| </xsl:when> | |
| <xsl:otherwise>1 x</xsl:otherwise> | |
| </xsl:choose> | |
| </td> | |
| <td><xsl:value-of select="text()" /></td> | |
| <td><xsl:value-of select="@date"/></td> | |
| </tr> | |
| </xsl:for-each> | |
| </table> | |
| </td> | |
| </tr> | |
| </xsl:for-each> | |
| </xsl:template> | |
| <!--Insert your code here--> | |
| </xsl:stylesheet> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment