[xsl] Best practices - using vars

Subject: [xsl] Best practices - using vars
From: xptm@xxxxxxx
Date: Mon, 23 Aug 2004 17:29:24 +0100
Hi again:

Using some "best practices" in order to achieve both readability and
performance, i ended up using a *lot* of vars. It really improves readability
but don't know about performance...

What is the cost of using vars? I'm doing this, for instance:

  <xsl:variable name="xtabnode">
    <xsl:value-of
select="document(concat('.\DicionarioXml\',$MasterTable,'.xml'))/Estrutura/Ta
belas/Tabela[Nome=$MasterTable]"/>
  </xsl:variable>
  <xsl:variable name="sqlInsert">
    <xsl:value-of select="sql:getStatement($MasterTable, $sql, $where,
$where,
$xtabnode, 'I' )" />
  </xsl:variable>
  <xsl:variable name="sqlUpdate">
    <xsl:value-of select="sql:getStatement($MasterTable, $sql, $where,
$where,
$xtabnode, 'U' )" />
  </xsl:variable>
  <xsl:variable name="sqlDelete">
    <xsl:value-of select="sql:getStatement($MasterTable, $sql, $where,
$where,
$xtabnode, 'D' )" />
  </xsl:variable>

  <xsl:template match="/">
    <XPage class="Tester" name="Tester"
    	sqlInsert = "{$sqlInsert}"
    	sqlUpdate = "{$sqlUpdate}"
    	sqlDelete = "{$sqlDelete}" >
(...)
     </XPage>
  </xsl:template>

I can have this instead:

 <xsl:template match="/">
    <XPage class="Tester" name="Tester"
    	sqlInsert = "{sql:getStatement($MasterTable, $sql, $where, $where,
$xtabnode, 'I' )}"
    	sqlUpdate = "{sql:getStatement($MasterTable, $sql, $where, $where,
$xtabnode, 'U' )}"
    	sqlDelete = "{sql:getStatement($MasterTable, $sql, $where, $where,
$xtabnode, 'D' )}" >

I tend to do this a lot, so creating a lot of vars.

Is it one better over the other ?

Thanks.






O SAPO ja esta livre de vmrus com a Panda Software, fique vocj tambim!
Clique em: http://antivirus.sapo.pt

Current Thread