Convert Negative to Positive
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 2
- Joined: Thu Jan 12, 2023 9:58 pm
Convert Negative to Positive
Post by FeelinGroovy »
Hello all,
Using XSLT to translate an incoming cXML OrderRequest transaction to an outgoing proprietary format for B to B eprocurement purchasing flow. My scenario is as follows. Any suggestions would be appreciated. Thanks!
In the incoming cXML OrderRequest we have a dollar amount being passed to us as a negative value:
<ItemFees>
<Fee>
<Type>Commission</Type>
<Amount currency="USD">-4.11</Amount>
</Fee>
</ItemFees>
I am mapping to that fee and passing it in the outgoing format in an Extrinsic line:
<Extrinsic name="54">-4.11</Extrinsic>
What I need to do is convert the negative value to a positive value by simply removing the dash "-" before the dollar amount. I've tried several things but can't get it to work.
My current XSLT config is as follows. Anyone know if there is a way in this command structure to remove that dash, or tell it to convert it to a positive value?
<Extrinsic name="54">
<xsl:value-of select="OrderReport/Item/ItemFees/Fee/Amount"/>
</Extrinsic>
Using XSLT to translate an incoming cXML OrderRequest transaction to an outgoing proprietary format for B to B eprocurement purchasing flow. My scenario is as follows. Any suggestions would be appreciated. Thanks!
In the incoming cXML OrderRequest we have a dollar amount being passed to us as a negative value:
<ItemFees>
<Fee>
<Type>Commission</Type>
<Amount currency="USD">-4.11</Amount>
</Fee>
</ItemFees>
I am mapping to that fee and passing it in the outgoing format in an Extrinsic line:
<Extrinsic name="54">-4.11</Extrinsic>
What I need to do is convert the negative value to a positive value by simply removing the dash "-" before the dollar amount. I've tried several things but can't get it to work.
My current XSLT config is as follows. Anyone know if there is a way in this command structure to remove that dash, or tell it to convert it to a positive value?
<Extrinsic name="54">
<xsl:value-of select="OrderReport/Item/ItemFees/Fee/Amount"/>
</Extrinsic>
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Convert Negative to Positive
Hi,
Maybe you can convert the text value to an xs:float and then add a minus before that:
Regards,
Radu
Maybe you can convert the text value to an xs:float and then add a minus before that:
Code: Select all
<xsl:variable name="val" select="-xs:float(text())" as="xs:float" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 2
- Joined: Thu Jan 12, 2023 9:58 pm
Re: Convert Negative to Positive
Post by FeelinGroovy »
Thanks for the reply. I will give this a try and will post the results.
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service