xsl-list
[Top] [All Lists]

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

2006-08-16 09:55:12
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:         Vårø, Denmark 06-09-25/10-06
World-wide corporate, govt. & user group UBL, XSL, & XML training.
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
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


--~------------------------------------------------------------------
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>