Frage

I looking to add a total (Sum) on the bottom of a table column with numbers. I can do this by using the XSLT 1.0 option mentioned in Aggregate-function for sum and product in XPath

However, I could also parse the XML source first in Java (it's part of a TeamSite install, which uses Java & XSLT 1.0) and add the sum there. Does anybody know how the efficiency of both solutions compare?

Note: the Java code does not parse the XML source already, so there is no efficiency to be gained.

Update

I made both solutions, and the Java solution seems to be a bit faster. However: I don't have exact metrics and I don't have a big example data set. I'm going to use the Java solution, mainly because of re-usability (i.e. using sub totals and grand totals) and the caching options that are available in Java.

War es hilfreich?

Lösung

There are many ways of doing it in Java, and there are many ways of doing it in XSLT, both in terms of how you write your code, and in terms of what products you use (e.g. different parsers, different tree models, different XSLT processors). Your results may well tell you more about your Java and XSLT programming skills than about the technology you are using. As @Tomalak says, measure it, publish your results, and invite people to comment on their validity / reproducibility.

It's quite likely the cost will be dominated by the cost of XML parsing, which is in principle the same either way. However, some tree models are more efficient than others; the DOM, which most people use, is probably the worst choice.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top