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

Re: Dynamic Table Generation

Subject: Re: Dynamic Table Generation
From: nigel.byrnes@xxxxxxxxxxx
Date: Fri, 10 Mar 2000 12:48:37 +0100
dynamic table content
Hi all

Thanks to the help I received earlier in the week on this list, I am making good progress. 

You'll remember that I was trying to generate a table of services (y-axis) and the content-types (x-axis) which listed the content types used by a particular service (much like a spreadsheet). While the stylesheet can build the table/column headings ok, 
the problem I have is when it comes to put crosses in the boxes marking the appropriate content types used. The template below performs the correctly when a service variant has zero or one content-types, note the correction to the XSL code enabling me to 
step through $content-types. 

The problem is when a service-variant uses multiple content-types. The template below adds another set of n 'td' elements for each content-type used by the service (where n is the size of the $cotent-types). The behaviour required is
- for exactly n td elements to be included in each row
- for a 'x' to put in the appropriate table-cell(s) indicating which content type(s) are used

What I think I need to do is:
- build each table row (of blank table cells) before entering into the foreach $content-types loop
- inside the foreach $content-types loop
  - perform the current test comparing $a to the ith content-type in $content-types
  - if the condition holds, add a 'x' to that 'td' element.

Trouble is I don't know how:
- to sample what the text value of the current element in XSL 
- to add text data to an element

Any ideas/comments will be welcome.

Thanks

Nigel

<!-- Contains the set of content types that can be used. -->
<xsl:variable name="requirements" 
	            select="//additionalHandsetFunctionality[not(.=following::additionalHandsetFunctionality)]"

<xsl:template match="service">
 <!-- Store the service name -->
 <xsl:variable name="name" select="name"/>
 <!-- for each variant of service which uses a different set of content-types. -->
 <xsl:for-each select="variant">
  <tr>
   <td><xsl:value-of select="$name"/></td>
   <td><xsl:value-of select="@type"/></td>
   <xsl:for-each select="service-content-type">
    <xsl:variable name="a" select="."/>
    <xsl:for-each select="$content-types">
     <!-- Note the correct form of the test condition below:-->
     <!-- It is comparing $a to the ith element of the $content-types -->
     <!-- The ith element of $content-types is identified by '.' -->
     <!-- not $content-types/content-type as was suggested -->
     <xsl:if test=".=$a/.">
      <td>x</td>
     </xsl:if>
    </xsl:for-each>
   </xsl:for-each>
  </tr>
 </xsl:for-each>
</xsl:template>


Nigel Byrnes, Philips Research
     Cross Oak Lane, Redhill. Surrey, RH1 5HA
Voice: +44 (0) 1293 815578
Fax: +44 (0) 1293 815500



 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.