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

Re: Variable number of attributes

Subject: Re: Variable number of attributes
From: "John E. Simpson" <simpson@xxxxxxxxxxx>
Date: Sat, 30 Sep 2000 12:53:49 -0400
variable number of table headers
At 09:17 AM 09/30/2000 -0400, John E. Simpson wrote:
[Not 100% correct stylesheet]

Sorry - copy-and-paste error. The example previously posted does not output the table headers. It should have actually been:


<?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>
           <tr>
             <xsl:for-each select="ele[1]/@*">
               <th><xsl:value-of select="name()"/></th>
             </xsl:for-each>
           </tr>
           <xsl:apply-templates />
         </table>
       </body>
     </html>
   </xsl:template>

   <xsl:template match="ele">
     <tr>
       <xsl:for-each select="@*">
         <td><xsl:value-of select="."/></td>
       </xsl:for-each>
     </tr>
   </xsl:template>

</xsl:stylesheet>

And the output from Saxon is:

<html xmlns="http://www.w3.org/TR/REC-html40">
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Attributes to Elements</title>
  </head>
  <body>
    <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>
  </body>
</html>

Sorry for the wasted bandwidth!

==========================================================
John E. Simpson | "Curiosity killed the cat,
http://www.flixml.org | but for a while I was a
XML Q&A: http://www.xml.com | suspect." (Steven Wright)



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.