Subject: Re: [xsl] Help on node selection From: Lars Huttar <lars_huttar@xxxxxxx> Date: Fri, 27 Aug 2010 11:42:20 -0500 |
On 8/27/2010 6:42 AM, Fabien Tillier wrote: > I want to first process nodes which have N1 = 1, then nodes with N1=2. But I want to call the template only once with all matching nodes (so once with N1=1 nodes, and once with N1=2 nodes), because I am building a group from these > Thus, I have tried with > > <xsl:apply-templates select="//row[N1=1]" mode="headers"/> > > But my template > > <xsl:template match="row" mode="headers"> > Headers > </xsl:template> > > Is called on each matching node...(thus 3 times here), rather than once, and then gets some loop to individually treat each node from the list. > How can I proceed ? If you are using XSLT 2.0, your outer template can say <myDoc> <xsl:for-each-group select="//row" group-by="N1"> <!-- this loop body is instantiated once for each group, e.g. N1=1 --> <xsl:element name="N1is{N1}"> <xsl:for-each select="current-group()"> <!-- this inner loop body is instantiated once for each row of the N1=1 group --> <xsl:value-of select="N2" />, </ </ </ </myDoc> And you get output like <myDoc> <N1is1>120, 120, 110</N1is1> <N1is2>120, 120</N1is2> </myDoc> (untested) Is that clearer? Lars
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Help on node selection, Dimitre Novatchev | Thread | [xsl] fo:table-cell with dynamical, Red Light |
Re: [xsl] Help on node selection, Martin Honnen | Date | Re: [xsl] Namespace issue when runn, Martin Honnen |
Month |