Re: [xsl] Best practices - using vars

Subject: Re: [xsl] Best practices - using vars
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 24 Aug 2004 09:54:04 +0100
  In the other cases, tought, you're saying it's best to use

    <xsl:variable name="sqlInsert" select="sql:getStatement($MasterTable, $sql,
  $where, $where, $xtabnode, 'I' )" />

  instead of

    <xsl:variable name="sqlInsert">
    <xsl:value-of select="sql:getStatement($MasterTable, $sql, $where, $where,
  $xtabnode, 'I' )" />

  because the first returns a string and the second a node with a node text that
  contains a string?

  Did i understand correctly?

well, the first might return a node or a string depending on the value
of the expression (I suppose it's a string in this case) the second is
expensive because it forces the. creation of a new tree with at least two
nodes in it.

so for example comparing

   <xsl:variable name="xtabnode">
   select="document(concat('.\DicionarioXml\',$MasterTable,'.xml'))/Estrutura/Tabelas/Tabela[Nome=$MasterTable]"/>


   <xsl:variable name="xtabnode">
     <xsl:value-of
   select="document(concat('.\DicionarioXml\',$MasterTable,'.xml'))/Estrutura/Tabelas/Tabela[Nome=$MasterTable]"/>
   </xsl:variable>

    In the particular case of xtabnode i realy want a node to be passed as argument
    to a Java method (that expects a org.w3c.dom.Node).

They both return something that probably coerces to that dom type.

The first really is a node at the Xpath level, a Tabela element node
from the original source tree.

The second isn't a node to XSLT1 it is a result tree fragment, but to
XSLT2 and probably any external API this is a _new_ tree with a newly
created root node containing a newly created text node that has string
value equal to the string value of the  Tabela element node
from the original source tree.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread