This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: row counting for html table creation


> I have an xml document of accounts like this...
>
> <bank>
>    <account>
>      <first_name>....</first_name>
>      <last_name>.....</last_name>
>      <address>.....</address>
>      <zip>.....</zip>
>      <balance>....</balance>
>    </account>
>
> etc etc
> </bank>
>
> and need to view them in an html table. The question
> is
> how can I generate the correct number of rows of my
> table
> based on the <account> element as it is changing
> depending
> on when I take a view of it, and secondly how can I
> insert
> the values of name, address etc into the columns?

No real difficulty here, if I've understood your requirement correctly.

Assuming the structure is regular (i.e. every account has the same
children).

<xsl:template match="bank">
<table>
<tr><xsl:apply-templates select="account[1]/*" mode="heading"/></tr>
<xsl:apply-templates/>
</table>
</xsl:template>

<xsl:template match="account">
<tr><xsl:apply-templates/></tr>
</xsl:template>

<xsl:template match="account/*">
<td><xsl:value-of select="."/></td>
</xsl:template>

<xsl:template match="account/*" mode="heading">
<th><xsl:value-of select="name()"/></th>
</xsl:template>

Mike Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]