|
Subject: RE: attribute list From: Mike Brown <mbrown@xxxxxxxxxxxxx> Date: Mon, 31 Jan 2000 13:49:51 -0700 |
Not sure why the subject is "attribute list", but...
> <CUSTOMER>
> <CUSTOMER_ID>0000000026</CUSTOMER_ID>
> <COMPANY>Aero Atlanta Fl</COMPANY>
> <NAME>Aero Atlanta Flying Club</NAME>
> <MAILBOX></MAILBOX>
> <STREET>P.O. Box 819</STREET>
> <POSTCODE>30144</POSTCODE>
> <CITY>Kennesaw,</CITY>
> <PHONE></PHONE>
> <FAX></FAX>
> </CUSTOMER>
>
>
> what i want to do is dynamically display the child elements
> as headers in an html table, like this :
>
> <table>
> <tr>
> <td>CUSTOMER_ID</td><td>COMPANY</td><td>NAME</td><td>MAILBOX</
> td><td>STREET<
> /td><td>POSTCODE</td><td>CITY</td><td>PHONE</td><td>FAX</td>
> </tr>
> <table>
If all CUSTOMERs have the same set of child element names, you can just look
at the first CUSTOMER and iterate through its child elements with something
like this:
<xsl:template match="/">
<table>
<!-- header row -->
<tr>
<xsl:for-each select="//CUSTOMER[1]/*">
<td><xsl:value-of select="name()"/></td>
</xsl:for-each>
</tr>
<xsl:for-each select="//CUSTOMER">
<!-- customer data row -->
<tr>
<xsl:for-each select="*">
<td><xsl:value-of select="."/></td>
</xsl:for-each>
</xsl:for-each>
</table>
</xsl:template>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| OASIS XSLT Conformance Subcommittee, G. Ken Holman | Thread | Newbie Question: Building Variables, jeffrod |
| Re: attribute list, Eric van der Vlist | Date | Re: question about call-template, Nikolai Grigoriev |
| Month |