ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xsl-list
xsl-list
RE: [xsl] Can you embed a filter test ahead of the format-number function in the xsl:value-of method
by other posts by this author
Nov 7 2001 6:36PM messages near this date
Re: [xsl] Can you embed a filter test ahead of the format-number function in the xsl:value-of method | Re: [xsl] Can you embed a filter test ahead of the format-number function in the xsl:value-of method
Joerg

I would try your suggestion but I should have
added that there are other things I need to
do inside the for-each so the filter
on the for-each would restrict the availability
of the returned result set ....

 <xsl:for-each select="NodeSomething"> 
	.
	.
	.
	<!-- do some other xslt things with all the other nodes and their
attributes... etc --> 	.
	.
	.
 <!-- just format the value of attribute2 if in face attribute2 is non
blank --> 
 <xsl:if test="./@attribute2 != ''"> 
 	<xsl:value-of select="format-number(./@attribute2,"#,###.00")"/> 
 </xsl:if> 
 </xsl:for-each> 

therefore...

	I need a less code bloat filter on attribute2 when it comes time in
	the syntax to begin working with attribute2....



 <xsl:for-each select="NodeSomething"> 
	.
	.
	.
	<!-- do some other xslt things with all the other nodes and their
attributes... etc --> 
	.
	.
	.
      <!-- just format the value of attribute2 if in face attribute2 is non
blank --> 
 	<xsl:value-of select="[./@attribute2 !=
'']format-number(./@attribute2,"#,###.00")"/> 
 </xsl:for-each> 



|-----Original Message-----
|From: owner-xsl-list@[...].com
|[mailto:owner-xsl-list@[...].com]On Behalf Of Jörg Heinicke
|Sent: Tuesday, November 06, 2001 3:07 PM
|To: xsl-list@[...].com
|Subject: Re: [xsl] Can you embed a filter test ahead of the
|format-number function in the xsl:value-of method
|
|
|Why not adding this filter directly to for-each?
|
|<xsl:for-each select="NodeSomething[@attribute2 != '']"> 
|     <xsl:value-of select="...."/> 
|</xsl:for-each> 
|
|Joerg
|
|jdgarrett@[...].net wrote:
|
|>  Given the following XML snippet
|> 
|> 
|>  <NodeSomething  attribute1="1234" attribute2="3">5678</NodeSomething>
|>  <NodeSomething  attribute1="12"   attribute2="">Abc</NodeSomething>
|>  <NodeSomething  attribute1="1256" attribute2="45">456</NodeSomething>
|>  <NodeSomething  attribute1="1298" attribute2="">8899</NodeSomething>
|> 
|>  I would like to change the following XSLT (which works but is code bloat)
|> 
|>  <xsl:for-each select="NodeSomething">
|>  <xsl:if test="./@attribute2 != ''">
|>  	<xsl:value-of select="format-number(./@attribute2,"#,###.00")"/>
|>  </xsl:if>
|>  </xsl:for-each>
|> 
|> 
|>  to the following (so that I can optimize the code)
|> 
|>  <xsl:for-each select="NodeSomething">
|>  	<xsl:value-of select="[./@attribute2 !=
|>  '']format-number(./@attribute2,"#,###.00")"/>
|>  </xsl:for-each>
|> 
|> 
|>  is it possible to embed a filter test ahead of the format-number
|function in
|>  the xsl:value-of so
|>  that if the filter test was true then and only then it would call the
|>  format-number
|>  function on the selected attribute rather than doing the xsl:if test and
|>  then
|>  calling the xsl:value-of method ??
|> 
|>  As you know, if attribute2 is empty then I get a NaN which format-number
|>  returns NaN
|>  rather than just nothing ....
|> 
|>  Please advise
|>  Thank You
|>  JGarrett
|> 
|> 
|> 
|> 
|>   XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
|> 
|> 
|> 
|
|
|--
|
|System Development
|VIRBUS AG
|Fon +49(0)341-979-7435
|Fax +49(0)341-979-7409
|joerg.heinicke@[...].de
|www.virbus.de
|
|
| XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
|



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
Thread:
=?ISO-8859-1?Q?J=F6rg?= Heinicke

=?iso-8859-1?Q?J=F6rg_Heinicke?=

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved