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

Re: more elegant way of doing this? (very simple)

Subject: Re: more elegant way of doing this? (very simple)
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 16 Aug 2006 12:54:11 -0400
Re:  more elegant way of doing this? (very simple)
At 2006-08-16 12:42 -0400, Steve wrote:
Summing up 3 specifically named nodes under Records/Record and summing
them only if they are numbers.

Current XSL===>

sum(Records/Record/*[name(.) = 'AContribution' and number(.) =
number(.) or name(.) = 'BContribution' and number(.) = number(.) or
name(.) = 'CContribution' and number(.) = number(.)])

The following would be more compact:


sum( ( Records/Record/AContribution | Records/Record/BContribution
     | Records/Record/CContribution )[number(.)=number(.)] )

It is not namespace-safe to use name(.).

I'm just trying to reduce redundancy.

You don't say *where* you want to reduce redundancy ... the above syntactically reduces your expression ... I cannot comment on the speed as that would be dependent on your processor so I don't think the question can be answered in that way.

I hope this helps.

. . . . . . . . . . . Ken

--
UBL/XML/XSLT/XSL-FO training:         Verx, Denmark 06-09-25/10-06
World-wide corporate, govt. & user group UBL, XSL, & XML training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

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-2011 All Rights Reserved.