You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Benoit Cerrina <be...@writeme.com> on 2000/10/20 09:16:43 UTC

breaking for-each, extension element suggestion

Hi,
I think I'll implement a new extension element used to break out of a for-each.
I'd have a use for this as an optimization, I have the need for looking up an element in a list of document, however I know that this element can be in at most one of those document so right now I have something like this
<xsl:for-each select="document(java:org.apache.xalan.xslt.extensions.Tokenizer.tokenize(@UsedDocs, ' ')/>
    <xsl:variable name="Target" select="key('ElementA', $Uuid)"/>
    <xsl:if test="$Target">
        ----------------------do something with Target e.g. <xsl:copy-of select="$Target"/>--------------------------
        <break/>
    </xsl:if>
</xsl:for-each>
Anybody else see the need for this?
Benoit

Re: breaking for-each, extension element suggestion

Posted by Benoit Cerrina <be...@writeme.com>.
Gary,
 I hadn't thought about this way of doing it, the idea though was to break
from the for each as soon as the first element conforming was found in order
to improve performance, not really to find a way to express my query which
work just fine.
I just happens that the processor continues to check for object with the
right idea in all the other documents which is not necessary. Actually since
the document call is done from within another for-each iterating other a
list of document names, this would even prevent unneeded document parsing.
Benoit
----- Original Message -----
From: "Gary L Peskin" <ga...@firstech.com>
To: <xa...@xml.apache.org>
Sent: Friday, October 20, 2000 9:23 AM
Subject: Re: breaking for-each, extension element suggestion


> > Benoit Cerrina wrote:
> >
> > Hi,
> > I think I'll implement a new extension element used to break out of a
> > for-each.
> > I'd have a use for this as an optimization, I have the need for
> > looking up an element in a list of document, however I know that this
> > element can be in at most one of those document so right now I have
> > something like this
> > <xsl:for-each
> >
select="document(java:org.apache.xalan.xslt.extensions.Tokenizer.tokenize(@U
sedDocs,
> > ' ')/>
> >     <xsl:variable name="Target" select="key('ElementA', $Uuid)"/>
> >     <xsl:if test="$Target">
> >         ----------------------do something with Target e.g.
> > <xsl:copy-of select="$Target"/>--------------------------
> >         <break/>
> >     </xsl:if>
> > </xsl:for-each>
> > Anybody else see the need for this?
> > Benoit
>
> Benoit --
>
> Couldn't you just implement this as a predicate?
>
> <xsl:for-each select="document(...)/*[. = key('ElementA', $Uuid)]">
>
> or something like that?
>
> Gary


Re: breaking for-each, extension element suggestion

Posted by Gary L Peskin <ga...@firstech.com>.
> Benoit Cerrina wrote:
> 
> Hi,
> I think I'll implement a new extension element used to break out of a
> for-each.
> I'd have a use for this as an optimization, I have the need for
> looking up an element in a list of document, however I know that this
> element can be in at most one of those document so right now I have
> something like this
> <xsl:for-each
> select="document(java:org.apache.xalan.xslt.extensions.Tokenizer.tokenize(@UsedDocs,
> ' ')/>
>     <xsl:variable name="Target" select="key('ElementA', $Uuid)"/>
>     <xsl:if test="$Target">
>         ----------------------do something with Target e.g.
> <xsl:copy-of select="$Target"/>--------------------------
>         <break/>
>     </xsl:if>
> </xsl:for-each>
> Anybody else see the need for this?
> Benoit

Benoit --

Couldn't you just implement this as a predicate?

<xsl:for-each select="document(...)/*[. = key('ElementA', $Uuid)]">

or something like that?

Gary