Altova Mailing List Archives


[xsl] how to do the expression and count function correctly?

From: "Zoe Peng" <zoe@------------>
To:
Date: 6/18/2002 12:31:00 PM
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

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.