This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Variable access
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "Satish, L. Gnanendra" <LGnanendra dot Satish at sciatl dot com>
- Cc: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Date: Fri, 20 Sep 2002 11:37:13 +0100
- Subject: Re: [xsl] Variable access
- Organization: Jeni Tennison Consulting Ltd
- References: <6973AC049FFDD41197BB0002A52916C619295E@bninchemex01.barconet.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Gnanendra,
> I would like to declare a variable and store the "Cleared" action in
> the <for-each> iteration, and then I have to access it again after
> the loop ends (It would be even more nice if I could break the loop
> on encountering the 'Cleared' text) to do some processing based on
> the status of the action. Can anyone help me with this?
Sure. If you change the way that you think about the problem, it
becomes a lot more obvious what the XSLT solution is. Instead of
saying *how* you want to get the result that you want, specify *what*
the result that you want is. In your case, think of it as:
"I want to work out whether any of the OIDMapping elements have an
ActionString element child whose value is 'Cleared'. If they do,
then I want to say 'YES'; if they don't I want to say 'NO'"
You can test whether there are any OIDMapping elements whose
ActionString element child is 'Cleared' by trying to select them:
MsgLevel/OIDInfo/OIDMapping[ActionString = 'Cleared']
So a solution is simply:
<xsl:template name="Call_ClearedBySystemMapped">
<xsl:choose>
<xsl:when test="MsgLevel/OIDInfo/OIDMapping
[ActionString = 'Cleared']">
<xsl:text>YES</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>NO</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list