Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6143867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:34:36+00:00 2026-05-23T18:34:36+00:00

I’ve been working on something for my boss, a website that displays the web-services

  • 0

I’ve been working on something for my boss, a website that displays the web-services of a ticketing system. The web-service spits out an XML file based on a query. My problem is, when I try to set conditions for output, I either get an error or it skips all the way to the “otherwise” entry when the array containing the XML entries for each ticket clearly match what I have in my test. I’m new to XSLT and have only what I’ve looked into to go off of. Can someone look at what I have and explain why this isn’t working? I know it’s just something to do with the test expression.

XML (output in array, don’t have original XML file)

    Array
(
    [RowCount] => 3
    [HasError] => false
    [ErrorMessage] => Array
        (
        )

    [StackTrace] => Array
        (
        )

    [IncidentList] => Array
        (
            [Incident] => Array
                (
                    [0] => Array
                        (
                            [GroupName] => EXTERNAL_SUPPORT
                            [IncidentNumber] => 229178
                            [OpenDateAndTime] => 2011-05-09T10:42:33
                            [State] => O
                            [StatusID] => EMAIL WIP
                            [SubjectID] => MAGIC
                            [UrgencyID] => NORMAL
                        )

                    [1] => Array
                        (
                            [GroupName] => CISS SYSTEMS
                            [IncidentNumber] => 203863
                            [OpenDateAndTime] => 2010-05-25T09:16:55
                            [State] => C
                            [StatusID] => CLOSED
                            [SubjectID] => ULID EXPIRATION
                            [UrgencyID] => NORMAL
                        )

                    [2] => Array
                        (
                            [GroupName] => HELP DESK 1ST LEVEL
                            [IncidentNumber] => 186909
                            [OpenDateAndTime] => 2009-09-11T09:58:44
                            [State] => C
                            [StatusID] => CLOSED
                            [SubjectID] => QUESTION
                            [UrgencyID] => NORMAL
                        )

                )

        )

)

What I’m using is this snippet of XSLT to display a table based on the State being O, C, or otherwise, display a message that there are no tickets to display.

<xsl:template match="/">
    <table id="myTable" class="list">
        <tr>
            <td class="title">Incident</td>
            <td class="title">Category</td>
            <td class="title">State</td>
            <td class="title">Status</td>
            <td class="title">Date</td>
        </tr>
        <xsl:choose>
            <xsl:when test="State = 'O'">
                <xsl:for-each select="Results/IncidentList/Incident">
                    <tr>
                        <td>#<xsl:value-of select="IncidentNumber"/></td>
                        <td><xsl:value-of select="SubjectID"/></td>
                        <td>OPEN</td>
                        <td><xsl:value-of select="StatusID"/></td>
                        <td>
                            <xsl:call-template name="formatDate">
                                <xsl:with-param name="dateTime" select="OpenDateAndTime" />
                            </xsl:call-template>
                        </td>
                    </tr>
                </xsl:for-each>
            </xsl:when>
            <xsl:when test="State = 'C'">
                <xsl:for-each select="Results/IncidentList/Incident">
                    <tr>
                        <td class="closed">#<xsl:value-of select="IncidentNumber"/></td>
                        <td class="closed"><xsl:value-of select="SubjectID"/></td>
                        <td class="closed">CLOSED</td>
                        <td class="closed"></td>
                        <td class="closed">
                            <xsl:call-template name="formatDate">
                                <xsl:with-param name="dateTime" select="OpenDateAndTime" />
                            </xsl:call-template>
                        </td>
                    </tr>
                </xsl:for-each>
            </xsl:when>
            <xsl:otherwise>
                <tr>
                    <td colspan="5">There are no incidents to display</td>
                </tr>
            </xsl:otherwise>
        </xsl:choose>
    </table>
</xsl:template>

</xsl:stylesheet>

I have tried every iteration of the test expression and I either get errors or it skips directly to the otherwise. Any help would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:34:36+00:00Added an answer on May 23, 2026 at 6:34 pm

    You probably meant this instead of your ‘xsl:when’s:

    <xsl:for-each select="Results/IncidentList/Incident[State = 'O']"> 
    

    and

    <xsl:for-each select="Results/IncidentList/Incident[State = 'C']">
    

    etc. The context on your ‘when’ condition in your example is not an Incident, but the root of the XML document. So you could also prefer:

    <xsl:for-each select="Results/IncidentList/Incident[State]">
       <xsl:choose>
          <xsl:when test="State = 'O'">..</xsl:when>
          <xsl:when test="State = 'C'">..</xsl:when>
          <Xsl:otherwise>..</xsl:otherwise>
       </xsl:choose>
    </xsl:for-each>
    

    Another alternative is using templates:

    <xsl:template match="/">
       ..
       <xsl:apply-templates select="Results/IncidentList/Incident[State]" />
       ..
    </xsl:template>
    
    <xsl:template match="Results/IncidentList/Incident[State = 'O']">..</xsl:template>
    <xsl:template match="Results/IncidentList/Incident[State = 'C']">..</xsl:template>
    ..
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.