xml - XSLT Not Taking When Test Selection -



xml - XSLT Not Taking When Test Selection -

i've been working on boss, website displays web-services of ticketing system. web-service spits out xml file based on query. problem is, when seek set conditions output, either error or skips way "otherwise" entry when array containing xml entries each ticket match have in test. i'm new xslt , have i've looked go off of. can @ have , explain why isn't working? know it's 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 snippet of xslt display table based on state beingness o, c, or otherwise, display message there no tickets 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 no incidents display</td> </tr> </xsl:otherwise> </xsl:choose> </table> </xsl:template> </xsl:stylesheet>

i have tried every iteration of test look , either errors or skips straight otherwise. help appreciated!

you meant instead of 'xsl:when's:

<xsl:for-each select="results/incidentlist/incident[state = 'o']">

and

<xsl:for-each select="results/incidentlist/incident[state = 'c']">

etc. context on 'when' status in illustration not incident, root of xml document. 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 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> ..

xml xslt testing

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -