| Subject: Re: [xsl] Select value by position From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 29 Aug 2006 11:38:22 +0100 | 
> Thanks for any tips how to improve performance..
> <xsl:variable name="identifier">
>    <xsl:value-of select="normalize-space(dc:identifier)"/>
> </xsl:variable>
Never use an xsl:variable with content like this unless you really need
to generate a new result tree fragment 9which is essentially a new node
tree with a root node (/) a text node with string value. that's
expensive to build and has to be coersed back to a string when used. You
just want a string here so
 <xsl:variable name="identifier">
   select="normalize-space(dc:identifier)"/>
which is less code to type and a lot more efficient (athough in this
case you don't really need a variable at all). In xslt1 that will use
the first dc:identifier, in xslt2 it will generate an error that there
is more than one. Tou sie the second you can use
 <xsl:variable name="identifier">
   select="normalize-space(dc:identifier[2])"/>
or [last()] or whatever predicate you need to specify.
  <rdf:Description>
	<xsl:attribute name="rdf:about"><xsl:value-of 
select="$identifier"/></xsl:attribute>
could be written more simply as
  <rdf:Description rdf:about="{$identifier}">
or just inline the variable if it is only used once:
  <rdf:Description rdf:about="{normalize-space(dc:identifier[2]}">
David
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| [xsl] Select value by position, Choi Ryan | Thread | [xsl] force apostrophed attribute v, Frank Marent | 
| Re: [xsl] force apostrophed attribu, Abel Online | Date | RE: [xsl] force apostrophed attribu, Michael Kay | 
| Month |