View Single Post
  #3 (permalink)  
Old June 6th, 2006, 03:02 PM
deltree deltree is offline
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by mhkay
 Firstly, don't do this:

<xsl:variable name="unit">
<xsl:value-of select="Selling_UM_1"/>
</xsl:variable>

when you could do this:

<xsl:variable name="unit" select="Selling_UM_1"/>

In the first case you are constructing a tree, which involves copying data and allocating memory. In the second case you are merely creating a reference to existing nodes without copying anything.

Secondly, what do you mean by "empty"? There's a difference between the element being absent, and the element being present but without any content. It might even be present with irrelevant content, e.g <Selling_UM_1> </Selling_UM_1>. For convenience, I'll assume that you test for emptyness by testing whether normalize-space(Selling_UM_1) is a zero-length string.

Your logic is then:

<xsl:choose>
  <xsl:when test="normalize-space($unit)">
    <a href="whatever"/>
  </xsl:when>
  <xsl:otherwise>#xa0;</xsl:otherwise>
</xsl:choose>




Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Worked great! Thanks!

Reply With Quote