[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: bizzare number problem

Subject: Re: bizzare number problem
From: "Vasu Chakkera" <vasucv@xxxxxxxxxxx>
Date: Wed, 26 Jan 2005 13:55:16 -0000
bizzare number
 <a
href="/malwareDirectory/variants/{translate(document('/malwareDirectory/fami
lies/index.xml')/malwareVariantFamilies/malwareFamily[@id
= $id]/variant[position() = 1]/@id, '/', '-')}.xml">

The above statement is a bit confusing. Could you please translate this for
us in plain english ??
One other thing there  should be curly braces around any xpath statement or
function , when it is used as a value of an attribute ( attribute value
template )
Refer : http://www.dpawson.co.uk/xsl/sect2/N1575.html

Cheers
Vasu
----- Original Message ----- 
From: <tom.kirkpatrick@xxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, January 26, 2005 1:09 PM
Subject: Re:  bizzare number problem


> Ok. The complete template is:
>
>   <xsl:template name="displayPrevalence">
>     <xsl:param name="year"/>
>     <xsl:param name="month" select="'NA'"/>
>     <xsl:param name="items" select="100"/>
>     <xsl:param name="method" select="'normal'"/>
>     <!-- start the table -->
>     <rawhtml>
>       <table class="layout vcard">
>         <tr class="greybox">
>           <th class="leftContent" style="width:100px !important;">
>                 Virus Name
>               </th>
>           <th>
>                 Prevalence
>               </th>
>           <th class="leftContent" style="width:60px !important;">
>                 Percentage
>               </th>
>               <xsl:if test="$method != 'lite'">
>           <th class="leftContent" style="width:60px !important;">
>                 Instances
>               </th>
>               </xsl:if>
>         </tr>
>             <!-- ensure month has a leading 0 (if set) -->
>             <xsl:variable name="prevMonth" select="format-number($month,
> '00')"/>
>             <!-- do the rows for a specific month-->
>             <xsl:for-each
>
select="document('/malwareDirectory/prevalence/index.xml')/malwarePrevalence
/malwareFamily/entry[@date
> = concat($year,$prevMonth)]">
>               <xsl:sort order="descending" select="@instances"
> data-type="number"/>
>               <xsl:if test="position() &lt;= $items">
>               <xsl:variable name="id" select="../@id"/>
>                 <tr>
>                   <th class="leftContent">
>                     <xsl:choose>
>                       <xsl:when
>
test="document('/malwareDirectory/families/index.xml')/malwareVariantFamilie
s/malwareFamily[@id
> = $id]/variant">
>                         <a
>
href="/malwareDirectory/variants/{translate(document('/malwareDirectory/fami
lies/index.xml')/malwareVariantFamilies/malwareFamily[@id
> = $id]/variant[position() = 1]/@id, '/', '-')}.xml">
>                           <xsl:value-of select="$id"/>
>                         </a>
>                       </xsl:when>
>                       <xsl:otherwise>
>                         <xsl:value-of select="$id"/>
>                       </xsl:otherwise>
>                     </xsl:choose>
>                   </th>
>                   <td>
>                     <xsl:variable name="currentNumber"
> select="ceiling(@percentage) * 0.95"/>
>                     <img src="/images/bgraph.gif" height="15"
> align="center" style="border:0px; padding:0px; margin:0px;"/>
>                     <img src="/images/ggraph.gif" height="15"
> align="center" style="border:0px; padding:0px; margin:0px;"
> width="{$currentNumber}"/>
>                     <img src="/images/bgraph.gif" height="15"
> align="center" style="border:0px; padding:0px; margin:0px;"/>
>                      <xsl:value-of select="$currentNumber"/> -
> <xsl:value-of select="ceiling(@percentage * 0.95)"/>
>                   </td>
>                   <td><xsl:value-of select="@percentage"/></td>
>                   <xsl:if test="$method != 'lite'">
>                     <td><xsl:value-of select="@instances"/></td>
>                   </xsl:if>
>                 </tr>
>               </xsl:if>
>             </xsl:for-each>
>       </table>
>     </rawhtml>
>   </xsl:template>
>
>
>
> I call it with a call like this:
>
>                   <xsl:call-template name="displayPrevalence">
>                     <xsl:with-param name="year" select="'2004"/>
>                     <xsl:with-param name="month" select="'11'"/>
>                     <xsl:with-param name="items" select="5"/>
>                     <xsl:with-param name="method" select="'lite'"/>
>                   </xsl:call-template>
>
>
>
> I am processing with Apache::AxKit
>
> I have narrowed the problem down to the choose element:
>
>                     <xsl:choose>
>                       <xsl:when
>
test="document('/malwareDirectory/families/index.xml')/malwareVariantFamilie
s/malwareFamily[@id
> = $id]/variant">
>                         <a
>
href="/malwareDirectory/variants/{translate(document('/malwareDirectory/fami
lies/index.xml')/malwareVariantFamilies/malwareFamily[@id
> = $id]/variant[position() = 1]/@id, '/', '-')}.xml">
>                           <xsl:value-of select="$id"/>
>                         </a>
>                       </xsl:when>
>                       <xsl:otherwise>
>                         <xsl:value-of select="$id"/>
>                       </xsl:otherwise>
>                     </xsl:choose>
>
> If I remove that it works fine. If I keep that, $currentNumber comes out
> as '-2.0465678427e23 +10'!
>
> -- 
> Tom David Kirkpatrick
> Virus Bulletin Web Developer, Virus Bulletin
>
> Tel: +44 1235 555139
> Web: www.virusbtn.com

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.