  | |  | AW: Tables Generation | AW: Tables Generation 2003-03-26 - By Stefan.Kaesberg@(protected)
Hi Vincent & Kevin,
it works as Kevin suggested with this stylesheet:
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output indent="yes" omit-xml-declaration="no" doctype-public="-//WAPFORUM//DTD XHTML Mobile 1.0//EN" doctype-system="http://www.wapforum.org/DTD/xhtml-mobile10.dtd"/> <xsl:template match="/parent"> <xsl:variable name="somechildren" select="*[@(protected) != '2' and @(protected) != '3']" /> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <body> <table border="1"> <xsl:call-template name="rows"> <xsl:with-param name="children" select="$somechildren"/> </xsl:call-template> </table> </body> </html> </xsl:template> <xsl:template name="rows"> <xsl:param name="children"/> <xsl:for-each select="$children" > <xsl:variable name="current_position" select="position()"/> <xsl:choose> <xsl:when test="position() mod 2 =1"> <tr> <!--<td>position :<xsl:value-of select="$current_position"/></td>--> <td><xsl:value-of select="@(protected)"/></td> <td><xsl:value-of select="$children[position()=($current_position+1)]/@(protected)"/> </td> </tr> </xsl:when> </xsl:choose> </xsl:for-each> </xsl:template> </xsl:stylesheet>
In Vincents stylesheet the last template matches to "site" and not to */child, furher more it goes through all selected nodes twice. You may replace the two templates by this:
<xsl:template mode="details" match="*"> <xsl:choose> <xsl:when test="position() mod 2 = 1"> <tr> <xsl:apply-templates mode="col" select="."/> <xsl:apply-templates mode="col" select="following-sibling::child[position() =1]"/> </tr> </xsl:when> </xsl:choose> </xsl:template> <xsl:template match="*" mode="col"> <td align="center"> child id <xsl:value-of select="@(protected)"/> </td> </xsl:template>
But here the "following-sibling" refers to the source tree and looses the information of cutting out element 2 and 3 - therefore you'll get : 1 2 5 6 istead of 1 4 5 6
I think you have to create the new nodeset with the filtered nodes to renumber the positions.
Hope that helps, Stefan
-----Urspr�ngliche Nachricht----- Von: klmccarthy@(protected) [mailto:klmccarthy@(protected)] Gesendet: Mi 26.03.2003 02:11 An: xalan-j-users@(protected) Cc: Betreff: Re: Tables Generation
Vincent, I think you have two options. You could create a node set in a variable which contains the desired child nodes. This would look something like this <xsl:variable name="somechildren" select=""*[@(protected) != '2' and @(protected) != '3']"/> Then you could pass this to the template by using call-template and a parameter. I think this would work, but is the wrong way to think about it. I think maybe there is something wrong with your apply-templates in the template where you process the child nodes. Some experiments there are in order. I'm not sure what to suggest off-hand. Kevin
|
|
 |