Subject: Re: Variable number of attributes From: "John E. Simpson" <simpson@xxxxxxxxxxx> Date: Sat, 30 Sep 2000 09:17:35 -0400 |
I'm trying to produce a single style sheet (foo.xsl) that offers the following functionality. I'm using IE 5.5. Any help would be greatly appreciated.
[snip]
And having a document:
<doc> <ele name1="A1" name2="A2" name3="A3"/> <ele name1="B1" name2="B2" name3="B3"/> </doc>
processed through the same tyle sheet (foo.xsl) produces:
<TABLE> <TR> <TH>name1</TH> <TH>name2</TH> <TH>name3</TH> </TR> <TR> <TD>A1</TD> <TD>A2</TD> <TD>A3</TD> </TR> <TR> <TD>B1</TD> <TD>B2</TD> <TD>B3</TD> </TR> </TABLE>
<html xmlns="http://www.w3.org/TR/REC-html40"> <head><title>Attributes to Elements</title></head> <body> <table> <tr> <td>A1</td> <td>A2</td> <td>A3</td> </tr> <tr> <td>B1</td> <td>B2</td> <td>B3</td> </tr> </table> </body> </html>
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/REC-html40" >
<xsl:template match="/doc"> <html> <head><title>Attributes to Elements</title></head> <body> <table> <xsl:apply-templates /> </table> </body> </html> </xsl:template>
<xsl:template match="ele"> <xsl:if test="position()=1"> <tr> <xsl:for-each select="@*"> <th><xsl:value-of select="name()"/></th> </xsl:for-each> </tr> </xsl:if> <tr> <xsl:for-each select="@*"> <td><xsl:value-of select="."/></td> </xsl:for-each> </tr> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Variable number of attributes, Aaron Bawcom | Thread | Re: Variable number of attributes, John E. Simpson |
Variable number of attributes, Aaron Bawcom | Date | XSL Formatting Objects Chapter Upda, Elliotte Rusty Harol |
Month |