Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - xslt: continue in for-each-group? >Thread Next - Re: xslt: continue in for-each-group? Re: xslt: continue in for-each-group?To: NULL Date: 2/5/2008 2:10:00 PM
bbembi_de@l... <bbembi_de@l...> wrote in
<8ba82eb2-d6b9-42db-bace-0b9bd566464d@d...>:
> <xsl:for-each-group select="item" group-by="name">
> <xsl:if test="contains(name, 'teststring11')">
> <xsl:apply-templates select="current-group()"/>
> </xsl:if>
> <xsl:if test="contains(name, 'teststring22')">
> <xsl:apply-templates select="current-group()"/>
> </xsl:if>
> </xsl:for-each-group>
>
> This xslt is fine, but has 1 problem: I want to make a
> "continue" in my if clauses. If the program walks into a
> if clause it should go to the next for-each-group. I don't
> want every if clause to be executed, only one.
While <xsl:choose/> is clearly an option, you might want to
consider the fact that specifying templates matching your
groups is often a better option. Your example seems to be
equivalent to:
<xsl:for-each-group select="item" group-by="name">
<xsl:apply-templates select="current-group()"/>
</xsl:for-each-group>
...but assuming you meant something like:
<xsl:for-each-group select="item" group-by="name">
<xsl:if test="contains(name,'teststring11')">
<xsl:apply-templates select="current-group()"
mode="mode-11"/>
</xsl:if>
<xsl:if test="contains(name,'teststring22')">
<xsl:apply-templates select="current-group()"
mode="mode-22"/>
</xsl:if>
</xsl:for-each-group>
...you might redesign that using just one template
application and properly matching templates, such as:
<xsl:template match="item[contains(name,'teststring11')]>
<Stuff-11/>
</xsl:template>
<xsl:template match="item[contains(name,'teststring22')]>
<Stuff-22/>
</xsl:template>
--
When all you have is a transformation engine, everything
looks like a tree.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
