| 
 
Subject: [xsl] how to do the expression and count function correctly?  From: "Zoe Peng" <zoe@xxxxxxxxxxxx> Date: Tue, 18 Jun 2002 16:29:02 -0400  | 
Hi, 
Please help about the expression and count function. 
if item_service exist, I want to display item_service_svc_id; 
otherwise, I want to display the item_id. 
Results I want: 
Top Stories: 7009
News: 3.2
the problem I am facing is: It always displays item_id(3.1, 3.2) cuz 
$nService is always grate than 1 in this case. what should I do?? any 
function I can use?? Thanks. 
--Zoe
<!-- xml document -->
<?xml version="1.0"?>
<tm_user_device_menu statuscode="0" statusdesc="OK">
<user_device usr_id="user1"  />
<menu>
       <item item_id="3.1" item_title="Top Stories" >
            <item_service item_service_type="default" 
item_service_svc_id="1000" item_service_usr_svc_nam="Top Stories" />
       </item>
       <item item_id="3.2" item_title="News" >
              <item item_id="3.2.1" item_title="US" >
                <item_service item_service_type="default" 
item_service_svc_id="1001" item_service_usr_svc_nam="US" />
              </item>
              <item item_id="3.2.2" item_title="Americas" 
item_dsc="America" item_image_path="/images/news.gif">
                <item_service item_service_type="default" 
item_service_svc_id="1002" item_service_usr_svc_nam="Americas" />
              </item>
        </item>
   </menu>
</tm_user_device_menu>
<!-- stylesheet -->
<xsl:variable name="nService">
                                <xsl:value-of select="count
(tm_user_device_menu/menu/item/item_service)" />
                            </xsl:variable>
<xsl:for-each 
select="tm_user_device_menu/menu/item">                                 
       <xsl:variable name="iId">
<xsl:value-of select="./@item_id" />
</xsl:variable>
<xsl:variable name="sId">
<xsl:value-of select="./item_service/@item_service_svc_id" />
</xsl:variable>
<xsl:variable name="sNam">
<xsl:value-of select="./item_service/@item_service_usr_svc_nam" />
</xsl:variable>
<anchor><xsl:value-of 
select="./@item_title" />                                             
<xsl:choose>
<xsl:when test="$nService = 0">
<go href="/menu{$url.sessionId}?MNUITEMID={$iId}" />
</xsl:when>
<xsl:otherwise >
<go href="/service{$url.sessionId}?SID={$sId}&USRSVCNAM={$sNam}" />
</xsl:otherwise>
</xsl:choose>
</anchor>
<br/>
</xsl:for-each> 
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| Current Thread | 
|---|
  | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Re: [xsl] XSL getting started (on a, Terje Norderhaug | Thread | Re: [xsl] how to do the expression , Amy Cheung | 
| Re: [xsl] CDATA question, Amy Cheung | Date | [xsl] testing child elements for te, CROFT, MICHAEL | 
| Month |