sum(@amount) only looks at one attribute node, presumably your real expression is something like sum(xxx/@amount). This will only look at amount attributes that actually exist. Is your problem that some attributes take the form amount=""? If you want to exclude these from the sum, use sum(xx/@amount[.!='']). More generally if you want to exclude any attribute whose value is non-numeric, use sum(xx/@amount[string(number(.)) != 'NaN'])
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference