|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
IIB9: XSD decimal |
« View previous topic :: View next topic » |
Author |
Message
|
akil |
Posted: Tue Oct 27, 2015 6:12 am Post subject: IIB9: XSD decimal |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
Hi
I've a XSD that defines an element to be of type xsd:decimal.
Code: |
<xsd:element name="BillingAmount">
<xsd:annotation>
<xsd:documentation>
This field contains the
amount in the card
account currency
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction
base="xsd:decimal">
<xsd:pattern
value="\d{1,9}\.\d{2}">
</xsd:pattern>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
|
I set the value in ESQL
Code: |
SET OutputRoot.XMLNSC.BillingAmountAmount = 100.00;
|
When I serialise it via ASBITSTREAM, I get the value as if the value was a float
Code: |
<BillingAmount>1E+2</BillingAmount>
|
But when I change the ESQL to specifically use a decimal
Code: |
SET OutputRoot.XMLNSC.BillingAmountAmount = CAST(100.00 AS DECIMAL);
|
I get the correct value
Code: |
<BillingAmount>100.00</BillingAmount>
|
Isn't the parser supposed to use the data-type specified in the XSD when it calls ASBITSTREAM? What can I do to avoid writing CAST AS DECIMAL in ESQL everytime I need to use ta decimal data-type? _________________ Regards |
|
Back to top |
|
 |
timber |
Posted: Tue Oct 27, 2015 7:39 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
It's a fair question, but that is not how XMLNSC works. The writing of OutputRoot.XMLNSC is tree-driven, not model-driven. So if the tree contains a FLOAT then a FLOAT will be written, even if the xsd specifies a DECIMAL.
If you switch on validation in the output node, the inconsistency will be detected and will result in a validation error. |
|
Back to top |
|
 |
mgk |
Posted: Tue Oct 27, 2015 8:06 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
You can also use a DECIMAL literal value as well instead if the value is a constant to save having to do a CAST.
Kind regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
akil |
Posted: Wed Oct 28, 2015 12:29 am Post subject: |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
Hi
Thanks ..
So the tree creates a data-type basis the ESQL variable's data-type, as it does not have any reference to the schema at that point..
While a mapping node creates the tree basis the XML schema, as it does indeed have a reference to the schema..
Is there any way to give a reference to the schema to ESQL ?
Regards
Akhilesh _________________ Regards |
|
Back to top |
|
 |
timber |
Posted: Wed Oct 28, 2015 2:54 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Quote: |
Is there any way to give a reference to the schema to ESQL ? |
Not for ESQL. But IIB is very flexible, and gives you several options:
- ESQL : Create any message tree structure you like. Does not have to conform to an XSD.
- Java : Same as ESQL by default. If you have xsds, you can generate JAXB classes and get an xsd-aware transformation language.
- Mapping node : Input and output message tree must always match an XSD.
Each has its advantages. Pick the one that suits your requirements. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|