Author |
Message
|
akil |
Posted: Thu Nov 13, 2014 3:08 am Post subject: IIB9: XMLNSC Domain, datetime, need serialisation with ms |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
Hi
Ok , this is possibly a poor implementation of a host system, which I cannot change, but I have to make calls to it via the broker ..
The host system publishes XSD's, which I comply with (schema validation turned on), and validation nodes included.
The host system however seems to be doing some custom (string) parsing of certain elements. Specifically for data and datetime elements. It expects these elements to necessarily contain milliseconds in the pattern (YYYY-MM-DDTHH24:MI:SS.SSS) , even when the milliseconds is .000.
The broker however, does not seem to serialise to milliseconds if the value of the milliseconds is zero.
What I do now is set the milliseconds to .001 to get the required output .. This however requires a lot of careful manual work .
How can I make this simpler to do ? _________________ Regards |
|
Back to top |
|
 |
kimbert |
Posted: Thu Nov 13, 2014 5:49 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I guess if you really need to conform to the published XSD then you don't have a lot of choice. Otherwise I would recommend that you model the field as a string, and use ESQL's CAST statement to achieve the required format.
You could still do that actually - but you would need to
- do the schema validation using ESQL's ASBITSTREAM function
- perform the CAST to CHARACTER specifying the required pattern
- setting the output field to the resulting CHARACTER value
( and make sure that validation is switched off in the Compute node properties - otherwise it will attempt to re-validate when it hits the output node ). _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Nov 13, 2014 7:10 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You may also want to look at the xsd.
If all that is published in the xsd it type xsd:date ot xsd:datetime, check what it would do to the output if you enhance the schema with the format.
For a date /time datetime entry you should be able to specify the format on the xsd itself...
Guaranteed it is pushing the maintenance from one part to another... Ultimately you'll have to do what is best for your site...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kimbert |
Posted: Thu Nov 13, 2014 7:42 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
For a date /time datetime entry you should be able to specify the format on the xsd itself |
I don't think so. As far as I'm aware, an xs:dateTime has a single allowable 'lexical format'. The is flexibility in the lexical format, but no way to specify an alternative format. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Nov 13, 2014 12:26 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
kimbert wrote: |
Quote: |
For a date /time datetime entry you should be able to specify the format on the xsd itself |
I don't think so. As far as I'm aware, an xs:dateTime has a single allowable 'lexical format'. The is flexibility in the lexical format, but no way to specify an alternative format. |
I stand corrected. Thanks Kimbert for setting me straight. _________________ MQ & Broker admin |
|
Back to top |
|
 |
akil |
Posted: Thu Nov 13, 2014 4:49 pm Post subject: |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
Thank you..I guess I will have to stick to the .001, I will try to enhance the schema to require a non zero milliseconds , that might help catch any misses in my code . _________________ Regards |
|
Back to top |
|
 |
kimbert |
Posted: Fri Nov 14, 2014 1:46 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I will try to enhance the schema to require a non zero milliseconds |
XMLNSC exactly follows the XML Schema specification. Here's what the XML Schema specification says about the dateTime type:
http://www.w3.org/TR/xmlschema-2/#dateTime
Note in particular section 3.2.7.1 Lexical Representation:
"'.' s+ (if present) represents the fractional seconds;"
So the fractional seconds are optional. There is no way to make them required.
Please see my first post on this thread for a suggestion that should work. If you need more details, feel free to ask. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
akil |
Posted: Fri Nov 14, 2014 7:03 am Post subject: |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
Hi
I have some 300 odd xsd's that I need to comply with .. It would be pretty tiring to change each one of them to replace the date time with a character.
Instead what I am doing is setting .001 as the milliseconds whenever I assign / move a value to such a field.
But even in this case, I sometimes forget to do this, and the host system rejects it ( this is even more difficult as i don't have direct access to the host system, I make the flow, test it against a mock that I have created and the. Ship it )..
I am trying to found a way to make sure that I have not missed setting .001 as milliseconds.. Is that possible , maybe as a global extension to the date ? _________________ Regards |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Nov 14, 2014 7:25 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You could write a tree walker program that would look for the type and verify the value (add .001) if not already present...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kimbert |
Posted: Fri Nov 14, 2014 8:45 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
It would be pretty tiring to change each one of them to replace the date time with a character |
I didn't advise you to edit the xsds. I advised you to write some ESQL that makes the output conform to the host system's requirements without altering the value.
I accept that either way you need to remember to put in that code ( or more likely, a call to that code ) each time you are writing a TIMESTAMP field into the output tree. And ESQL does not make it easy to determine whether a field is a TIMESTAMP field.
You could perform a recursive tree walk using some Java code - then you could use Java's instanceof to work out what the data type is. However, the simplest and cheapest fix is to get the host system to accept valid XML. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
akil |
Posted: Fri Nov 14, 2014 9:46 am Post subject: |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
I misunderstood your initial post, sorry about that .
I'll write the tree walker , in my mock server , that way I can get warned of a missing millisecond without an additional overhead at runtime. Also, I use mapping nodes at all possible times, ( for it's self documenting capability ), and want to avoid falling back on ESQL for a host system defect..
Getting the host system changed is a task by itself, will it give it a try, quoting the spec.. _________________ Regards |
|
Back to top |
|
 |
|