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

XSLT 1.0 : HTML table with

Subject: XSLT 1.0 : HTML table with
From: jeanph01 <jeanph01@xxxxxxxx>
Date: Wed, 21 Apr 2010 16:18:43 -0400
 XSLT 1.0 : HTML table with
 I want to create a table with xslt 1.0 from an XML source file containing a
varying number of key for each row :

 <?xml version="1.0" encoding="ISO-8859-1" ?>
 <output>
   <SearchResults>
     <SearchResult>
       <OTCreateDate>2009-10-27</OTCreateDate>
       <OTCreatedByFullName>Jean-Philippe Martin</OTCreatedByFullName>
       <Score>97</Score>
     </SearchResult>
     <SearchResult>
       <Attr_4539360_16>Nord</Attr_4539360_16>
       <Attr_4539360_26>Transfirer</Attr_4539360_26>
       <OTCreateDate >2007-08-30</OTCreateDate>
       <OTCreatedByFullName >Caroline</OTCreatedByFullName>
       <Score>94</Score>
     </SearchResult>
   </SearchResults>
 </output>


 So here my first key <SearchResult> have 3 sub-keys. But the second
<SearchResult> key have 5 sub-keys. I don't know what key will be present in
the set since it's a search result.

 This would have to give an html which would look like this with 5 columns:

 <html>
     <body>
         <table>
             <thead>
                 <tr>
                     <th>OTCreateDate</th>
                     <th>OTCreatedByFullName</th>
                     <th>Score</th>
                     <th>Attr_4539360_16</th>
                     <th>Attr_4539360_26</th>
                 </tr>
             </thead>
             <tbody>
                 <tr>
                     <td>2009-10-27</td>
                     <td>Jean-Philippe Martin</td>
                     <td>97</td>
                     <td></td>
                     <td></td>
                 </tr>
                 <tr>
                     <td>2007-08-30</td>
                     <td>Caroline</td>
                     <td>94</td>
                     <td>Nord</td>
                     <td>Transfirer</td>
                 </tr>
             </tbody>
         </table>
     </body>
 </html>


 First, can it be done ?

 For the head row  I managed to get the unique key names with a M. Kay
algorithm I found but how to link a specific TD to its TH ?

   <xsl:template match="/">
     <table border="1">
       <thead>
         <tr>
           <xsl:for-each select="//SearchResult/*">
             <xsl:sort select="name(.)"/>
             <xsl:if test="generate-id(.) = generate-id(key('names',
name(.))[1])">
               <th>
                 <xsl:value-of select="local-name()"/>
               </th>
             </xsl:if>
           </xsl:for-each>
         </tr>
       </thead>
     </table>
   </xsl:template>


 Thank you for any help.

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.