You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Alex Speed <al...@luckymonkey.co.uk> on 2002/02/28 23:41:39 UTC

Conditional Logic Help

I need to filter out two things (A and B) when I do a <xsl:for-each .... ,
so I tried

<xsl:for-each select="dataelement[RESOURCETYPE/text()!='A'] | dataelement
[RESOURCETYPE/text()!='B']">

but that didn't work, so I tried seperating it out into 2 for-each
statements (one to filter out A, one to filter out B) but that didn't work,
so I tried filtering out A in the for-each and then trying

<xsl:if test="dataelement[RESOURCETYPE/text()!='B']">
.....
</xsl:if>

to filter out B, but this doesn't seem to work either, and its not very
elegant.

Are there any better ideas?


Re: Conditional Logic Help

Posted by Alex Speed <al...@luckymonkey.co.uk>.
Ahh, thats the ticket - much better thanks :D

----- Original Message -----
From: "Gene Roske" <Ge...@Computer.org>
To: "Alex Speed" <al...@luckymonkey.co.uk>
Cc: <xa...@xml.apache.org>
Sent: Thursday, February 28, 2002 11:33 PM
Subject: Re: Conditional Logic Help


> Alex -
>
> It appears that you want "and" rather than "or".  This filter passes
> everything.  It would pass "A" because it is not equal to "B", and "B"
because
> it not "A".  Also, these should be contained in one conditional
expression.
> (Note the position of the brackets "[]".
>
> Try "not 'A' and not 'B'"  or  "not('A' or 'B')":
>
> <xsl:for-each select="dataelement[RESOURCETYPE/text()!='A' and
> RESOURCETYPE/text()!='B']">
>
>          or
>
> <xsl:for-each select="dataelement[not(RESOURCETYPE/text()='A' |
> RESOURCETYPE/text()='B')]">
>
>
>                      - Gene Roske
>
>
> >
> > I need to filter out two things (A and B) when I do a <xsl:for-each ....
,
> > so I tried
> >
> > <xsl:for-each select="dataelement[RESOURCETYPE/text()!='A'] |
dataelement
> > [RESOURCETYPE/text()!='B']">
> >
> > but that didn't work, so I tried seperating it out into 2 for-each
> > statements (one to filter out A, one to filter out B) but that didn't
work,
> > so I tried filtering out A in the for-each and then trying
> >
> > <xsl:if test="dataelement[RESOURCETYPE/text()!='B']">
> > .....
> > </xsl:if>
> >
> > to filter out B, but this doesn't seem to work either, and its not very
> > elegant.
> >
> > Are there any better ideas?
>
>


Re: Conditional Logic Help

Posted by Gene Roske <Ge...@Computer.org>.
Alex -

It appears that you want "and" rather than "or".  This filter passes
everything.  It would pass "A" because it is not equal to "B", and "B" because
it not "A".  Also, these should be contained in one conditional expression.
(Note the position of the brackets "[]".

Try "not 'A' and not 'B'"  or  "not('A' or 'B')":

<xsl:for-each select="dataelement[RESOURCETYPE/text()!='A' and
RESOURCETYPE/text()!='B']">

         or

<xsl:for-each select="dataelement[not(RESOURCETYPE/text()='A' |
RESOURCETYPE/text()='B')]">


                     - Gene Roske


>
> I need to filter out two things (A and B) when I do a <xsl:for-each .... ,
> so I tried
>
> <xsl:for-each select="dataelement[RESOURCETYPE/text()!='A'] | dataelement
> [RESOURCETYPE/text()!='B']">
>
> but that didn't work, so I tried seperating it out into 2 for-each
> statements (one to filter out A, one to filter out B) but that didn't work,
> so I tried filtering out A in the for-each and then trying
>
> <xsl:if test="dataelement[RESOURCETYPE/text()!='B']">
> .....
> </xsl:if>
>
> to filter out B, but this doesn't seem to work either, and its not very
> elegant.
>
> Are there any better ideas?