Solved

Error: xsl:choose cannot be a child of the 'xls:choose' element

Posted on 2012-03-28
10
477 Views
Last Modified: 2012-03-29
Why am i unable to place a choose within another choose, when the code already allowed me to do before?
What would be a workaround then?

<xsl:variable name="tempVar">
      <xsl:choose>
            <xsl:when test="count($Match) = 0">
                  <xsl:choose>
                        <xsl:when test="contains($FAILED,DI/OU)">N</xsl:when>

                                <xsl:choose>  <!-- ERROR: xsl:choose cannot be a child of the 'xls:choose' element -->
                                <xsl:when test="count($MatchFL1) > 0">RE</xsl:when>
                                    <xsl:otherwise>
                                    <xsl:when test="count($MatchFL2) > 0">RE</xsl:when>
                                    </xsl:otherwise>
                                </xsl:choose>
                                       
                        <xsl:otherwise>Y</xsl:otherwise>
                  </xsl:choose>
            </xsl:when>
            <xsl:when test="contains($FAILED,DI/OU)">
                  <xsl:choose>
                        <xsl:when test="contains($FAILED,$Match/Code)">N</xsl:when>
                        <xsl:otherwise>Y</xsl:otherwise>
                  </xsl:choose>
            </xsl:when>

            <xsl:when test="$tmp = 'ETE' or $off = 'ETA'">N</xsl:when>

        <xsl:otherwise>Y</xsl:otherwise>
      </xsl:choose>
</xsl:variable>
0
Comment
Question by:badtz7229
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 37778904
<xsl:when test="contains($FAILED,DI/OU)">N</xsl:when>
note that you already closed the xsl:when
which means the choose is a sibling to xsl:when, not a child
0
 

Author Comment

by:badtz7229
ID: 37778946
However,even if I commented that line out, I still get the warning.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 37778965
what I mean is:
you need to wrap the choose inside the when.
Right now your choose is a direct child of another choose.
That si not allowed.
only when and otherwise can be children of a choose
so if you need a choose inside a choose, the inner choose needs to be a child of either a when branche or an otherwise branch

you have
choose
---when
---choose
------when

where you need
choose
---when
------choose
---------when

does that make sense?
0
Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

 

Author Comment

by:badtz7229
ID: 37779009
Can you give me an example?
I still don't understand why I can't have a choose inside another choose
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 37779054
well, a choose has by definition a series of when branches and zero or one otherwise
the exectution of a choose works as follows
only execute the first when clause that has a @test that evaluates to true, and if none evaluate to true, execute the otherwise branch (if there is one)

If you want to have a choose inside a choose, you need to have it inside one of the when branches. Outside it makes no sense.

What exactly do you want to achieve?
0
 

Author Comment

by:badtz7229
ID: 37781940
i guess the only way i can make my code work is to do the following:

so if count >0 then choose either one of the cases below.

           <xsl:when test="count($Match) = 0">
                  <xsl:choose>
                        <xsl:when test="contains($FAILED,DI/OU)">N</xsl:when>
                         <xsl:when test="count($MatchFL1) > 0">RE</xsl:when>
                         <xsl:when test="count($MatchFL2) > 0">RE</xsl:when>
                              ........
thx anyway
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 37782031
well, I still don't understand how you want to conceptually have a choose directly inside a choose, since the inner choose is not an alternative branche on its own

A choose needs to have a series of alternative branches. If you want to have a new condition inside one of the branches, you can do

or you can be more precise in the original statements

I would rewrite your piece of code above like this
<xsl:choose>
        <xsl:when test="not($Match) and contains($FAILED,DI/OU)">N</xsl:when>
        <xsl:when test="not($Match) and ($MatchFL1 | $MatchFL2)">RE</xsl:when>
                              ........

Open in new window

0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 37782039
note that I prefer not($Match) over count($Match) = 0
and that I combined the FL1 and FL2
0
 

Author Closing Comment

by:badtz7229
ID: 37783884
good idea. thx
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 37783894
welcome
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question