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

Re: Select value by position

Subject: Re: Select value by position
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 29 Aug 2006 11:38:22 +0100
Re:  Select value by position
> 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

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.