Subject: Re: [xsl] xsl template for simple data-base to transform into html displayable table From: "cking" <cking@xxxxxxxxxx> Date: Thu, 2 Sep 2004 23:50:57 +0200 |
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" /> <xsl:template match="/"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Purchase-Orders</title> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="Purchase-Orders"> <table border="1"> <tr> <th>name</th> <th>address</th> <th>phone-number</th> <th>part-number</th> <th>quantity</th> <th>price</th> <th>total</th> </tr> <xsl:apply-templates select="Purchase-Order"/> </table> </xsl:template> <xsl:template match="Purchase-Order"> <tr><xsl:apply-templates/></tr> </xsl:template> <xsl:template match="Purchase-Order/*"> <td><xsl:value-of select="."/></td> </xsl:template> </xsl:stylesheet> This will work if you are certain that the children of <Purchase-Order> always occur in the same order. If you're not, you can replace the last two templates with this one: <xsl:template match="Purchase-Order"> <tr> <td><xsl:value-of select="name"/></td> <td><xsl:value-of select="address"/></td> <td><xsl:value-of select="phone-number"/></td> <td><xsl:value-of select="part-number"/></td> <td><xsl:value-of select="quantity"/></td> <td><xsl:value-of select="price"/></td> <td><xsl:value-of select="total"/></td> </tr> </xsl:template> Cheers, Anton Triest
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] xsl template for simple data-, Bovy, Stephen J | Thread | Re: [xsl] xsl template for simple d, Brandon Schenz |
RE: [xsl] xsl template for simple d, Pieter Reint Siegers | Date | Re: [xsl] xsl template for simple d, Brandon Schenz |
Month |