File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Could I sum Nodes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Could I sum Nodes?" Watch "Could I sum Nodes?" New topic

Could I sum Nodes?

Alex Philippi

Joined: Oct 05, 2007
Posts: 13
Hi, this is perhaps a weird question, but I have three nodes like these:


I am able to sum all fields with position 1, but I want only to display this position 1 one time in the transformed xml file. It should look like this:

But it look like this:

Is it possible to "say" in the xslt file to only print the position 1 only one time?

I hope you can help me

Best Regards
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
I guess it is possible.

Q. How to ask an XSLT question?
The easiest way to get answer real quick is post the original xml source, then post what you want to get the xml/html result. Of course, make it simple, and illustrate the point you want to solve only. Then your own approach which does not work as you desired. Many brain exercisers will solve your problem quickly. The answer will help others too.

* Do not throw the entire document here
* Do your own homework!
* Simplify the part you have problem with. Abstraction is a basic skill for programmers.
* Make both source and result well-formed XML.
* During this process, you might solve your own problem.
* If not, post a good question on a public forum.

Copied from
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Here is a useful set of pages about XSLT. Your particular problem is classified as "Grouping".
I agree. Here's the link:
subject: Could I sum Nodes?
jQuery in Action, 3rd edition