tesmc
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/ACCP T/USD1500/ 075XG CCVIXXXXXXXXXXXX1237E</Tex t>
</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.
<root>
<Envelope>
<Body>
<Response>
<Itin>
<Services Item="005"">
<Service Code="SOS">
<Extensions>
<Type>PAYMENT</Type>
</Extensions>
<Text>RA UK1 YVRYYZ0702P01DEC/SEAT/ACCP
</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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think this should work
<xsl:value-of select="format-number(($am 1 + $am2) div 100, ' 0.00')"/>
<xsl:value-of select="format-number(($am
ASKER
that prefixes the total with 11 spaces + value of sum. instead of have the whole value be contained within 11 spaces.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks. all of it worked. i appreciate it.
welcome
ASKER
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