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

RE: hoe to use "(" within a variable

Subject: RE: hoe to use "(" within a variable
From: "Andrew Welch" <awelch@xxxxxxxxxxxxxxx>
Date: Mon, 12 Aug 2002 14:22:30 +0100
use variable within always
> In my mind, best practice is that if you can set a variable directly
> to a string, number, boolean or node set then it's much better to do
> so than it is to go through a result tree fragment.

Thanks Jeni,

clear as always

cheers
andrew


> -----Original Message-----
> From: Jeni Tennison [mailto:jeni@xxxxxxxxxxxxxxxx]
> Sent: 12 August 2002 12:44
> To: Andrew Welch
> Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  hoe to use "(" within a variable
> 
> 
> Hi Andrew,
> 
> > Can you highlight the differences of using the select 
> attribute (over
> > rtf content) when using variables.
> >
> > Using this case as an example,
> >
> > <xsl:variable name"foo" select="sprintf(log_str, '\n%s: %d: 
> %s:%s')"/>
> 
> You mean:
> 
> <xsl:variable name"foo"
>               select='"sprintf(log_str, &apos;\n%s: %d: 
> %s:%s&apos;)"' />
> 
> > against:
> >
> > <xsl:variable name="foo">sprintf(log_str, '\n%s: %d:
> > %s:%s')</xsl:variable>
> >
> > As you have said one would require escaping of quotes, and the other
> > is technically a result-tree-fragment, but getting the value-of
> > produces the same results.
> >
> > What is best practice here?
> 
> In my mind, best practice is that if you can set a variable directly
> to a string, number, boolean or node set then it's much better to do
> so than it is to go through a result tree fragment.
> 
> When you use a result tree fragment, the processor has to create at
> least two new nodes (a root node and a text node); creating nodes and
> storing that is a *lot* more burdensome (takes up more processing time
> and memory) than storing the value directly. The result tree fragment
> needs to be converted to a string/number/boolean/node-set when you use
> it, which also takes time compared to using the value directly.
> Finally, I find it easy to mistakenly test variables with:
> 
>   <xsl:if test="$foo">
>     ...
>   </xsl:if>
> 
> which is always true for a result tree fragment, and wouldn't
> necessarily be for a string.
> 
> Having to escape the quotes is a pain, but I think that "if you can,
> use the select attribute" is a heuristic that will generally stand you
> in good stead.
>   
> Cheers,
> 
> Jeni
> 
> ---
> Jeni Tennison
> http://www.jenitennison.com/
> 
> 
> 
> 
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.381 / Virus Database: 214 - Release Date: 02/08/2002
>  
> 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 02/08/2002
 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.