Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: xslt: continue in for-each-group?

From: "bbembi_de@-----.--" <------_--@-----.-->
To: NULL
Date: 2/5/2008 11:36:00 PM
Thanks very much for the info.

Now I found out what my real problem is (I tried xsl:choose before
writing the first mail):

I have a xml like this:

<root>
   <item name="111">
      <subitem name="aaa">
      <subitem name="bbb">
   </item>....

I group the subitems but only want to output a item name once.
I want only one item output.

<xsl:for-each-group select="subitem" group-by="name">
      <xsl:apply-templates select="current-group()" //here I output
the name of the parent (item) but this should be only once for every
item.

bye bembi






On 5 Feb., 13:10, Pavel Lepin <p.le...@ctncorp.com> wrote:
> bbembi...@lycos.de <bbembi...@lycos.de> wrote in
> <8ba82eb2-d6b9-42db-bace-0b9bd5664...@d21g2000prf.googlegroups.com>:
>
> > <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.



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent