0

i have a code like this in XSLT 1.0: <xsl:value-of select="sum(//section1[(field1 = $field1) and (field2 = $field2) and (field3 = $field3))]/Amount/text())"/>

i receive field 'Amount' with double quotes, like this "456.89". Then when i sum it i got NaN. How can i remove double quotes or ignore them during sum function? Please remember that solution should be in XSLT 1.0. I already tried with translate: <xsl:value-of select="sum(//translate(section1[(field1 = $field1) and (field2 = $field2) and (field3 = $field3))]/Amount/text(), '&quot;', ''))"/> , but it doesn't work. Here is sample which i receive:

<root>
    <section1>
        <field1>1</field1>
        <field2>2</field2>
        <field3>3</field3>
    </section1>
    <section1>
        <Amount>"10.05"</Amount>
        <field1>1</field1>
        <field2>2</field2>
        <field3>3</field3>
        <Amount>"15.10"</Amount>
    </section1>
    <section1>
        <field1>4</field1>
        <field2>5</field2>
        <field3>5</field3>
        <Amount>"10"</Amount>
    </section1>
</section1>
</root>
Thank you in advance.
  • Could you update the post with the corresponding XML sample? – choroba Aug 23 '21 at 08:54
  • this sample is of course fake, but sense is still the same, i need to sum Amount fields, but first remove (translate) or ignore double quotes in some way. So question is how to remove or ignore double quotes in the same query with sum. Here is XML: – Ivan Yurchenko Aug 23 '21 at 09:01
  • See https://stackoverflow.com/q/26750513/1030675 on how to remove the double quotes. – choroba Aug 23 '21 at 09:17

0 Answers0