[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: attribute list

Subject: RE: attribute list
From: Mike Brown <mbrown@xxxxxxxxxxxxx>
Date: Mon, 31 Jan 2000 13:49:51 -0700
attribute list
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.