xsl-list
[Top] [All Lists]

Re: [xsl] Select value by position

2006-08-29 03:38:44

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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>