This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to do the expression and count function correctly?


try 
<xsl:when test="./item_service">
or <xsl:when test="count(./item_service)=0">
in place of 
<xsl:when test="$nService = 0">


--- Zoe Peng <zoe@allfools.net> wrote:
> 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}&amp;USRSVCNAM={$sNam}"
> />
> </xsl:otherwise>
> </xsl:choose>
> </anchor>
> <br/>
> </xsl:for-each> 
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]