Author |
Message
|
sasad |
Posted: Thu Sep 18, 2014 1:08 am Post subject: Dynamically setting min occurs in mapping node |
|
|
Acolyte
Joined: 30 Apr 2014 Posts: 67
|
Hi all,
I want to dynamically set min occurs property to 0 or 1 depending on the value of other field in model. for e.g
I have two fields MessageType and Status. If MessageType is 'AB' then Status in message is required (min Occurs should be '1'). If MessageType is 'AC' then Status is not required (min Occurs should be '0').
Can this be done in Message Model?
Thanks, |
|
Back to top |
|
 |
Vitor |
Posted: Thu Sep 18, 2014 4:41 am Post subject: Re: Dynamically setting min occurs in mapping node |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
sasad wrote: |
Can this be done in Message Model? |
Depending on which version you're using (hence MRM or DFDL) use the AB or AC to drive a choice. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
sasad |
Posted: Thu Sep 18, 2014 4:51 am Post subject: |
|
|
Acolyte
Joined: 30 Apr 2014 Posts: 67
|
Message model type is DFDL. I tried this by setting an expression in OccursCountKind property.
Field separator for DFDL is '|'. Below is part of actual model. I tried parsing a file with transaction type 'MPC' and no 'NEWMPIN' field. It is parsing successfully instead of throwing an error. as per expression 'NewMPIN' field should be required if Transaction type is 'MPC', but this is not working.
Code: |
<xsd:element ibmSchExtn:docRoot="true" name="Step1VerificationReqModel">
<xsd:complexType>
<xsd:sequence dfdl:separator="|" dfdl:separatorSuppressionPolicy="trailingEmpty">
<xsd:element ibmDfdlExtn:sampleValue="value1" name="MessageType" type="xsd:string"/>
<xsd:element ibmDfdlExtn:sampleValue="value2" name="TransactionType" type="xsd:string"/>
<xsd:element ibmDfdlExtn:sampleValue="value3" name="CNIC" type="xsd:string"/>
<xsd:element name="MobileNumber" type="xsd:string"/>
<xsd:element dfdl:occursCount="{xs:nonNegativeInteger(if (fn:contains('MPG',/Step1VerificationReqModel/TransactionType) or fn:contains('MPC',/Step1VerificationReqModel/TransactionType)) then 1 else 0)}" dfdl:occursCountKind="expression" minOccurs="0" name="OldMPIN" type="xsd:string"/>
<xsd:element dfdl:occursCount="{xs:nonNegativeInteger(if (fn:contains('MPC',/Step1VerificationReqModel/TransactionType)) then 1 else 0)}" dfdl:occursCountKind="expression" minOccurs="0" name="NewMPIN" type="xsd:string"/>
<xsd:element dfdl:terminator="" minOccurs="0" name="Terminator" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element> |
|
|
Back to top |
|
 |
Vitor |
Posted: Thu Sep 18, 2014 6:03 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
sasad wrote: |
Message model type is DFDL. I tried this by setting an expression in OccursCountKind property. |
And that doesn't work? Wow, I wish I'd suggested using a choice rather than setting that.
 _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
sasad |
Posted: Thu Sep 18, 2014 6:06 am Post subject: |
|
|
Acolyte
Joined: 30 Apr 2014 Posts: 67
|
I don't know how to use choice.  |
|
Back to top |
|
 |
Vitor |
Posted: Thu Sep 18, 2014 6:46 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
sasad wrote: |
I don't know how to use choice.  |
Well one day it's likely you'll need to, even if not for this, so some research and learning would seem to be in order. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
sasad |
Posted: Thu Sep 18, 2014 11:03 pm Post subject: |
|
|
Acolyte
Joined: 30 Apr 2014 Posts: 67
|
I have Schema for ISO8583. It has Primary Bit map field which is used to tell if field(s) is present or not in message. expression in OccusCountKind property is used for all other fields. Which is working totally fine. I don't understand why this is not working in my case.
@Vitor Can you suggest me some examples of Choice , I tried some search but didn't find any useful links. |
|
Back to top |
|
 |
|