Subject: Re: Dynamic Table Generation From: nigel.byrnes@xxxxxxxxxxx Date: Fri, 10 Mar 2000 12:48:37 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Dynamic Table Generation, David Carlisle | Thread | Re: Dynamic Table Generation, David Carlisle |
More namespace fun?, Pawson, David | Date | Ignore childs, Marta Lobato |
Month |