xsl-list
[Top] [All Lists]

Re: [xsl] shortest way to write this xsl:if statement

2012-06-15 08:34:08
You don't need an if, the XPath should produce all nodes according to
the condition. So, just the xsl:for-each!

On 15/06/2012, henry human <henry_human(_at_)yahoo(_dot_)de> wrote:
sorry, but the resul with the xpath- query is the same. The if statement is
ended after first finding of 'A'

but there are at least for findings for B, C, D which should lead to
creation of the code bellow of th if-statement
??



----- Ursprüngliche Message -----
Von: Wolfgang Laun <wolfgang(_dot_)laun(_at_)gmail(_dot_)com>
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
CC:
Gesendet: 15:17 Freitag, 15.Juni 2012
Betreff: Re: [xsl] shortest way to write this xsl:if statement

Sorry, I meant to indicate that this should produce all the nodes that
should be processed by the loop,

  <xsl:for-each select="....">

On 15/06/2012, Wolfgang Laun <wolfgang(_dot_)laun(_at_)gmail(_dot_)com> wrote:
You might need an XPath expression
   test="D4/G10/(X,Y,Z)[. = ('A','B','C','D')]"
-W


On 15/06/2012, henry human <henry_human(_at_)yahoo(_dot_)de> wrote:
Now the problem is, the loop bellow of xsl:if is only one time created
but
I
have more findings in the if statement
regarding A, B, C, D (founds at least 4 times because D4/G100/6id = 'A' ,
D4/G100/9id = 'B' , D4/G100/10id = 'C' , D4/G100/11id ='D')
=> the code bellow of the xsl:if statemnt should be repeated as much as
if
statement find A, B, C, D,..




----- Ursprüngliche Message -----
Von: G. Ken Holman <gkholman(_at_)CraneSoftwrights(_dot_)com>
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com; 
"xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com"
<xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
CC:
Gesendet: 13:59 Freitag, 15.Juni 2012
Betreff: Re: [xsl] shortest way to write this xsl:if statement


At 2012-06-15 12:54 +0100, henry human wrote:
Hello
The following if statement is too long if try it as in the sample
bellow.
How could be shorter?
The if - logic to create a for-each loop:
----------------
xsl:if
D4/G100/6id  or D4/G100/9id or D4/G100/12id or D4/G100/6id15 or
D4/G100/45id or D4/G100/22id, D4/G100/10id
or D4/G100/19id is 'A' or 'B' or 'C', or 'D' or 'F'

The Sample:
<xsl:if test="D4/G100/6id = 'A' OR test="D4/G100/6id = 'B' OR
test="D4/G100/6id = 'C' OR test="D4/G100/9id = 'A' OR test="D4/G100/9id
=
'B' .....>

<xsl:for-each select=" ......">
...
</xsl:for-each>

</xsl:if>

Element names cannot begin with digits, so I'm unclear how you are going
to
be testing elements such as <6id>.

But, assuming you had elements D4/G100/X and D4/G100/Y and D4/G100/Z, you
could have in XSLT2 the following:

<xsl:if test="D4/G100/(X,Y,Z) = ('A','B','C')">

... which is equivalent to:

  D4/G100/X = 'A' or
  D4/G100/X = 'B' or
  D4/G100/X = 'C' or
  D4/G100/Y = 'A' or
  D4/G100/Y = 'B' or
  D4/G100/Y = 'C' or
  D4/G100/Z = 'A' or
  D4/G100/Z = 'B' or
  D4/G100/Z = 'C'

When using the "=" comparison operator, either operand can be a set.  The
processor walks through the comparisons in an arbitrary order eventually
testing each of the left operand with each of the right operand and stops
when it hits a true() result and returns true().  If you get a false()
returned, you know the processor has checked every possible combination
and
every combination has returned false().

I hope this helps.

. . . . . . . . . . . Ken

--
Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   
mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--