View Single Post
  #1 (permalink)  
Old December 5th, 2008, 05:59 AM
nwright nwright is offline
Registered User
 
Join Date: Mar 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default sum and translate in XPath

My XML has commas in the numbers so I'm using translate in order to treat as numerical values.
I now need to get the sum of a nodeset and have an issue when attempting to use sum and translate together.

I'm using XPath 1.0

Example XML
<?xml version="1.0" encoding="UTF-8"?>
<items>
    <item>thing one</item>
    <item>thing two</item>
    <value>1,500</value>
    <value>3,700</value>
</items>

The XPath I'm using will never work as sum returns the nodeset and translate only a single item so even if it worked it would only get one item.

Xpath
sum(translate(//value,",",""))

Is there any way to do this or should I run a transform to remove commas?