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

which is faster?

Subject: which is faster?
From: tom.kirkpatrick@xxxxxxxxxxxx
Date: Fri, 4 Feb 2005 09:27:55 +0000
ide es id
I have a template which does a lookup from an exernal file. Currently I am 
doing it like so.

<!-------------
<xsl:template name="displayPrevalenceReport">
  <xsl:param name="malwareFamilyId"/>
  <xsl:param name="items" select="10"/>
  <xsl:param name="method" select="'normal'"/>
 
  <!-- load in required indexes -->
  <xsl:variable name="malwarePrevalence" 
 
select="document('/malwareDirectory/prevalence/index.xml')/malwarePrevalence"/>

  <!-- do the rows -->
  <xsl:for-each select="$malwarePrevalence/malwareFamily[@id = 
$malwareFamilyId]/entry">
    <xsl:sort order="descending" select="@date"/>
    <xsl:if test="position() &lt;= $items">
      <xsl:variable name="year" select="substring(@date, 1, 4)"/>
      <xsl:variable name="month_position" select="substring(@date, 5, 
6)"/>
      <xsl:variable name="month"
 select="document('/global/autodate.xml')/date/month[@position = 
$month_position]/@name"/>

      <xsl:value-of select="concat($month, ' ', $year)"/>

      <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="{ceiling(@percentage) 
* 0.95}%"/>

      <img src="/images/bgraph.gif" height="15" align="center" 
style="border:0px; padding:0px; margin:0px;"/>

      <xsl:value-of select="@percentage"/>% <br/>

      <xsl:value-of select="@instances"/> instances <br />

    </xsl:if>
  </xsl:for-each>
</xsl:template>
<!-------------

The external file looks a bit like this (although it actually contains 
about 12000 lines of code and is about 600k on disk):

<!-------------
<?xml version="1.0"?>
<malwarePrevalence>
  <malwareFamily id="1099">
    <entry date="199504" instances="1" percentage="0.9"/>
  </malwareFamily>
  <malwareFamily id="10_Past_3.748">
    <entry date="199808" instances="1" percentage="0.5"/>
  </malwareFamily>
  <malwareFamily id="2K-674">
    <entry date="199602" instances="1" percentage="0.3"/>
  </malwareFamily>
  <malwareFamily id="2lines">
    <entry date="199705" instances="1" percentage="0.3"/>
  </malwareFamily>
  <malwareFamily id="A&amp;A.506">
    <entry date="199611" instances="1" percentage="0.1"/>
  </malwareFamily>
  <malwareFamily id="ABC">
    <entry date="199712" instances="1" percentage="0.2"/>
    <entry date="199801" instances="2" percentage="0.4"/>
    <entry date="199802" instances="1" percentage="0.2"/>
    <entry date="199803" instances="2" percentage="0.5"/>
    <entry date="199805" instances="2" percentage="0.5"/>
  </malwareFamily>
  <malwareFamily id="Angelina">
    <entry date="199709" instances="2" percentage="0.7"/>
    <entry date="199802" instances="7" percentage="1.6"/>
    <entry date="199804" instances="4" percentage="1.0"/>
    <entry date="199805" instances="2" percentage="0.5"/>
    <entry date="199806" instances="1" percentage="0.2"/>
    <entry date="199808" instances="5" percentage="2.4"/>
    <entry date="199809" instances="2" percentage="0.9"/>
    <entry date="199810" instances="1" percentage="0.2"/>
    <entry date="199811" instances="2" percentage="0.5"/>
    <entry date="199903" instances="23" percentage="0.4"/>
    <entry date="199908" instances="1" percentage="0.05"/>
    <entry date="199910" instances="1" percentage="0.05"/>
  </malwareFamily>
</malwarePrevalence>
<!-------------

So as you can see, first I load the external file into a variable for easy 
access, then I do a for-each loop on the specific parts of the file I want 
to proecss. What I want to know is if I am going about this in a decent 
manor, or if I am making the computer do unnessecary work.

The problem (if there is one) probably lays with the call to the external 
file. Perhaps I should be using keys somehow to speed it all up? Or 
perhaps I should load only the parts of that external file into this 
stylesheet rather than the entire document. Or seing as I only want to 
process the first 10 elements, is there a way to load only those ones into 
the stylesheet?


Many thanks to anyone who can give me some pointers.

-- 
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.