Author |
Message
|
j.f.sorge |
Posted: Mon May 18, 2009 12:07 am Post subject: [solved] modelling CWF message with mandatory fields |
|
|
Master
Joined: 27 Feb 2008 Posts: 218
|
Hello!
I have imported a COBOL copy book to create a CWF message. This message contains a header with mandatory fields. I tried to model this by setting Nillable to false and minOccurs / maxOccurs to 1 and a padding / encoding null value of SPACE. When I try to validate a message containing only SPACES in a mandatory field I thought the validation to fail but it parses correctly.
Does anyone know how to model such a field in CWF?
Thanks in advance! _________________ IBM Certified Solution Designer - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Last edited by j.f.sorge on Mon May 18, 2009 4:37 am; edited 1 time in total |
|
Back to top |
|
 |
Vitor |
Posted: Mon May 18, 2009 12:24 am Post subject: Re: modelling CWF message with mandatory fields |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
j.f.sorge wrote: |
When I try to validate a message containing only SPACES in a mandatory field I thought the validation to fail but it parses correctly. |
Am I correct in saying the intention here if for the message set to fail parsing if this field is present but space filled; i.e. it's not the field that's mandatory but it's content? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
j.f.sorge |
Posted: Mon May 18, 2009 12:29 am Post subject: Re: modelling CWF message with mandatory fields |
|
|
Master
Joined: 27 Feb 2008 Posts: 218
|
Vitor wrote: |
j.f.sorge wrote: |
When I try to validate a message containing only SPACES in a mandatory field I thought the validation to fail but it parses correctly. |
Am I correct in saying the intention here if for the message set to fail parsing if this field is present but space filled; i.e. it's not the field that's mandatory but it's content? |
Yes, you are right. Parsing / validating should fail if the content of the field is only SPACE / null. _________________ IBM Certified Solution Designer - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
Vitor |
Posted: Mon May 18, 2009 12:43 am Post subject: Re: modelling CWF message with mandatory fields |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
j.f.sorge wrote: |
Yes, you are right. Parsing / validating should fail if the content of the field is only SPACE / null. |
And you have the validation set to content and value? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
j.f.sorge |
Posted: Mon May 18, 2009 1:14 am Post subject: Re: modelling CWF message with mandatory fields |
|
|
Master
Joined: 27 Feb 2008 Posts: 218
|
Vitor wrote: |
And you have the validation set to content and value? |
I am using WMB 6.0.0.3 with a subflow to validate the messages. This subflow contains a ResetContentDescriptorNode with Parse timing=complete and a ValidateNode afterwards with Validate=Content and Value. _________________ IBM Certified Solution Designer - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
kimbert |
Posted: Mon May 18, 2009 2:24 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I tried to model this by setting Nillable to false and minOccurs / maxOccurs to 1 and a padding / encoding null value of SPACE |
You have misunderstood the null handling properties. The null handling facilities of the MRM parser allow you to specify what a null value looks like.
If the MRM parser finds that the input matches the literal or logical null value, then it will set the value in the message tree to NULL.
Similarly, when writing a message, if the message tree element contains the value NULL the output bit stream will contain the appropriate bytes.
Your requirement is nothing to do with null handling; you can forget Nillable and Encoding Null. You want to check that the value of a field is correct. You can do that in the following ways:
- set the logical type to some non-string type ( such as xs:int ). If the input is not a valid number, it will be reported as a data conversion error.
- create a simple type based on xs:string and and add Value Constraints ( same as XML Schema facets ) to it. Without knowing what 'valid' means I cannot suggest what those should be. |
|
Back to top |
|
 |
j.f.sorge |
Posted: Mon May 18, 2009 2:30 am Post subject: |
|
|
Master
Joined: 27 Feb 2008 Posts: 218
|
kimbert wrote: |
Your requirement is nothing to do with null handling; you can forget Nillable and Encoding Null. You want to check that the value of a field is correct. You can do that in the following ways:
- set the logical type to some non-string type ( such as xs:int ). If the input is not a valid number, it will be reported as a data conversion error.
- create a simple type based on xs:string and and add Value Constraints ( same as XML Schema facets ) to it. Without knowing what 'valid' means I cannot suggest what those should be. |
The values which I get in the message are all of xs:string type and I do not know a list of correct values. The only thing I want to check is if the field does only contain SPACES. If this is true validation should fail. _________________ IBM Certified Solution Designer - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
kimbert |
Posted: Mon May 18, 2009 2:35 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Then add a pattern Value Constraint to your simple type to express that rule. |
|
Back to top |
|
 |
j.f.sorge |
Posted: Mon May 18, 2009 4:26 am Post subject: |
|
|
Master
Joined: 27 Feb 2008 Posts: 218
|
kimbert wrote: |
Then add a pattern Value Constraint to your simple type to express that rule. |
Thanks a lot! That helped me out.
Adding a minimum length of 1 to the type definition lets messages fail which have only SPACES. _________________ IBM Certified Solution Designer - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
Vitor |
Posted: Mon May 18, 2009 4:33 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
j.f.sorge wrote: |
Adding a minimum length of 1 to the type definition lets messages fail which have only SPACES. |
Unless it's a field 10 characters long space filled I imagine....  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|