Avatar of badtz7229
badtz7229Flag 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.
CSSXML

Avatar of undefined
Last Comment
Gertone (Geert Bormans)

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Gertone (Geert Bormans)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
badtz7229

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
Gertone (Geert Bormans)

I think this should work
        <xsl:value-of select="format-number(($am1 + $am2) div 100, '          0.00')"/>
ASKER
badtz7229

that prefixes the total with 11 spaces + value of sum. instead of have the whole value be contained within 11 spaces.
Your help has saved me hundreds of hours of internet surfing.
fblack61
SOLUTION
Gertone (Geert Bormans)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
badtz7229

thanks. all of it worked. i appreciate it.
Gertone (Geert Bormans)

welcome