Link to home
Start Free TrialLog in
Avatar of tesmc
tesmcFlag for United States of America

asked on

XSL: Retrieve text value as currency and add it

I have the following input XML.

<root>
      <Envelope>
            <Body>
             <Response>
              <Itin>
                  <Services Item="005"">
                        <Service Code="SOS">
                        <Extensions>
                            <Type>PAYMENT</Type>
                        </Extensions>
                                    <Text>RA UK1 YVRYYZ0702P01DEC/SEAT/ACCPT/USD1500/075XG CCVIXXXXXXXXXXXX1237E</Text>                        
                        </Service>
                  </Services>
             <Itin>                  
            </Response>
            </Body>
      </Envelope>
</root>                  

I want to get the Text value when the Type="PAYMENT" and @Code="SOS" and store it into a variable.
Then in the variable grab 2 substring values (after USD) and add it.
In this case, 1500 and 075; With decimal place 2 places from the right, so 15.00 and 00.75
Then the total would be 15.75

I want to store all 3 currencies into 3 separate variables.
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tesmc

ASKER

thanks that worked great.
also, how would i pad the values with empty spaces?
for instance am1 and am2 has to be enclosed within 11 spaces regardless of amount.
For example
<15.00      > 11 spaces or
<125.00     > 11 spaces
I think this should work
        <xsl:value-of select="format-number(($am1 + $am2) div 100, '          0.00')"/>
Avatar of tesmc

ASKER

that prefixes the total with 11 spaces + value of sum. instead of have the whole value be contained within 11 spaces.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tesmc

ASKER

thanks. all of it worked. i appreciate it.