Yep that was clear from the translate bit...
what is /malwareDirectory/variants/ doing there before the translate???
That doesnt look like a proper xpath to me
vasu
----- Original Message -----
From: <tom(_dot_)kirkpatrick(_at_)virusbtn(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Wednesday, January 26, 2005 2:08 PM
Subject: Re: [xsl] bizzare number problem
there is curly braces around the xpath bit of the attribute value:
{translate(document('/malwareDirectory/fami
lies/index.xml')/malwareVariantFamilies/malwareFamily[(_at_)id
= $id]/variant[position() = 1]/@id, '/', '-')}
In plain english. This looks up
/malwareVariantFamilies/malwareFamily[(_at_)id = $id]/variant[position() =
1]/@id
in the document '/malwareDirectory/families/index.xml'
the value of /malwareVariantFamilies/malwareFamily[(_at_)id =
$id]/variant[position() = 1]/@id
will result in something lik 'W32/Netsky.a' - The corrisponding filename
will be 'W32-Netsky.a'
So the translate() changes '/' to '-' in the id attribute of
/malwareVariantFamilies/malwareFamily[(_at_)id = $id]/variant[position() = 1]
in the document '/malwareDirectory/families/index.xml'
"Vasu Chakkera" <vasucv(_at_)hotmail(_dot_)com>
26/01/2005 13:55
Please respond to xsl-list
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
cc:
Subject: Re: [xsl] bizzare number problem
<a
href="/malwareDirectory/variants/{translate(document('/malwareDirectory/fami
lies/index.xml')/malwareVariantFamilies/malwareFamily[(_at_)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(_dot_)kirkpatrick(_at_)virusbtn(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Wednesday, January 26, 2005 1:09 PM
Subject: Re: [xsl] 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[(_at_)date
= concat($year,$prevMonth)]">
<xsl:sort order="descending" select="@instances"
data-type="number"/>
<xsl:if test="position() <= $items">
<xsl:variable name="id" select="../@id"/>
<tr>
<th class="leftContent">
<xsl:choose>
<xsl:when
test="document('/malwareDirectory/families/index.xml')/malwareVariantFamilie
s/malwareFamily[(_at_)id
= $id]/variant">
<a
href="/malwareDirectory/variants/{translate(document('/malwareDirectory/fami
lies/index.xml')/malwareVariantFamilies/malwareFamily[(_at_)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[(_at_)id
= $id]/variant">
<a
href="/malwareDirectory/variants/{translate(document('/malwareDirectory/fami
lies/index.xml')/malwareVariantFamilies/malwareFamily[(_at_)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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--
Tom David Kirkpatrick
Virus Bulletin Web Developer, Virus Bulletin
Tel: +44 1235 555139
Web: www.virusbtn.com
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--