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)
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of badtz7229
badtz7229
Flag of United States of America image

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 badtz7229
badtz7229
Flag of United States of America image

ASKER

that prefixes the total with 11 spaces + value of sum. instead of have the whole value be contained within 11 spaces.
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of badtz7229
badtz7229
Flag of United States of America image

ASKER

thanks. all of it worked. i appreciate it.
welcome
CSS
CSS

Cascading Style Sheets (CSS) is a language used for describing the look and formatting of a document written in a markup language. Usually used to change web pages and user interfaces written in HTML, it can also be applied to any kind of XML document. CSS is designed primarily to distinguish the content of a document from its presentation.

43K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo