ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexWebSphere Message Broker SupportDFDL Message Parsing with 'choice' tag

Post new topicReply to topic
DFDL Message Parsing with 'choice' tag View previous topic :: View next topic
Author Message
mhasan23
PostPosted: Mon Jul 22, 2019 12:37 am Post subject: DFDL Message Parsing with 'choice' tag Reply with quote

Novice

Joined: 12 Oct 2017
Posts: 19

Dear All,

I am trying to parse fixed length message dynamically. I have created a message model defined below;


Code:
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:ibmDfdlExtn="http://www.ibm.com/dfdl/extensions" xmlns:ibmSchExtn="http://www.ibm.com/schema/extensions" xmlns:recFixLengthFieldsFmt="http://www.ibm.com/dfdl/RecordFixLengthFieldFormat">

    <xsd:import namespace="http://www.ibm.com/dfdl/RecordFixLengthFieldFormat" schemaLocation="IBMdefined/RecordFixLengthFieldFormat.xsd"/>
    <xsd:annotation>
      <xsd:appinfo source="http://www.ogf.org/dfdl/">
         <dfdl:format encoding="{$dfdl:encoding}" escapeSchemeRef="" occursCountKind="fixed" ref="recFixLengthFieldsFmt:RecordFixLengthFieldsFormat"/>
      </xsd:appinfo>
   </xsd:annotation>

   <xsd:element dfdl:lengthKind="delimited" ibmSchExtn:docRoot="true" name="PHX_GDCI_Sample">
      <xsd:complexType>
         <xsd:sequence dfdl:separator="" dfdl:separatorSuppressionPolicy="anyEmpty">
            <xsd:element dfdl:lengthKind="delimited" name="MessageHeader">
               <xsd:complexType>
                  <xsd:sequence>
                     <xsd:element dfdl:length="7" dfdl:lengthUnits="characters" ibmDfdlExtn:sampleValue="head_valu1" name="MessageProtocol" type="xsd:string"/>
                     <xsd:element dfdl:length="2" dfdl:lengthUnits="characters" dfdl:textNumberPattern="#0" name="Version" type="xsd:string"/>
                     <xsd:element dfdl:length="3" dfdl:textNumberPattern="#0" name="FieldinError" type="xsd:string"/>
                            <xsd:element dfdl:length="4" dfdl:textNumberPattern="#0" name="MessageType" type="xsd:string"/>
                            <xsd:element dfdl:length="14" dfdl:textNumberPattern="#0" name="TransmissionDateandTime" type="xsd:integer"/>
                            <xsd:element dfdl:length="2" dfdl:textNumberPattern="#0" name="DeliveryChannelType" type="xsd:string"/>
                            <xsd:element dfdl:length="20" ibmDfdlExtn:sampleValue="head_value7" name="DeliveryChannelID" type="xsd:string"/>
                            <xsd:element dfdl:length="30" dfdl:truncateSpecifiedLengthString="yes" name="CustomerIdentification" type="xsd:string"/>
                            <xsd:element dfdl:length="3" dfdl:textNumberPattern="#0" name="TransactionCode" type="xsd:string"/>
                            <xsd:element dfdl:length="8" dfdl:textNumberPattern="#0" name="TransactionDate" type="xsd:integer"/>
                            <xsd:element dfdl:length="6" dfdl:textNumberPattern="#0" name="TransactionTime" type="xsd:integer"/>
                            <xsd:element dfdl:length="12" dfdl:textNumberPattern="#0" name="RetrievalReferenceNumber" type="xsd:integer"/>
                            <xsd:element dfdl:length="20" dfdl:truncateSpecifiedLengthString="yes" ibmDfdlExtn:sampleValue="head_value13" name="CustomerPINData" type="xsd:string"/>
                            <xsd:element dfdl:length="80" dfdl:truncateSpecifiedLengthString="yes" ibmDfdlExtn:sampleValue="head_value14" name="ChannelSpecificDataField" type="xsd:string"/>
                            <xsd:element dfdl:length="20" dfdl:truncateSpecifiedLengthString="yes" ibmDfdlExtn:sampleValue="head_value15" name="ChannelPrivateData" type="xsd:string"/>
                            <xsd:element dfdl:length="6" ibmDfdlExtn:sampleValue="head_value16" name="AuthorizationResponseId" type="xsd:string"/>
                            <xsd:element dfdl:length="2" ibmDfdlExtn:sampleValue="head_value17" name="ResponseCode" type="xsd:string"/>
            <xsd:choice dfdl:initiator="" dfdl:terminator="">
                             
                                           <xsd:annotation>
            <xsd:appinfo source="http://www.ogf.org/dfdl/">
              <dfdl:discriminator message="">{/PHX_GDCI_Sample/MessageHeader/TransactionCode eq '302'}</dfdl:discriminator>
            </xsd:appinfo>
          </xsd:annotation>
                    <xsd:element dfdl:length="16" dfdl:lengthUnits="characters" dfdl:outputNewLine="%CR;%LF;" name="PinBlock_New" type="xsd:string">
           
                                              <xsd:annotation>
                    <xsd:appinfo source="http://www.ogf.org/dfdl/">
                      <dfdl:discriminator>{/PHX_GDCI_Sample/MessageHeader/TransactionCode eq '302'}</dfdl:discriminator>
                    </xsd:appinfo>
                  </xsd:annotation>
                                </xsd:element>
                                                            <xsd:element dfdl:length="20" dfdl:lengthUnits="characters" dfdl:outputNewLine="{}" name="PAN" type="xsd:string">
         <xsd:annotation>
                    <xsd:appinfo source="http://www.ogf.org/dfdl/">
                      <dfdl:discriminator>{/PHX_GDCI_Sample/MessageHeader/TransactionCode eq '302'}</dfdl:discriminator>
                    </xsd:appinfo>
                  </xsd:annotation>
          </xsd:element>
       
        <xsd:element dfdl:length="2" name="DCType" type="xsd:string">
         <xsd:annotation>
                    <xsd:appinfo source="http://www.ogf.org/dfdl/">
                      <dfdl:discriminator>{/PHX_GDCI_Sample/MessageHeader/TransactionCode eq '302'}</dfdl:discriminator>
                    </xsd:appinfo>
                  </xsd:annotation>
          </xsd:element>
       
        <xsd:element dfdl:length="4" name="CardExpiry" type="xsd:string">
         <xsd:annotation>
                    <xsd:appinfo source="http://www.ogf.org/dfdl/">
                      <dfdl:discriminator>{/PHX_GDCI_Sample/MessageHeader/TransactionCode eq '303'}</dfdl:discriminator>
                    </xsd:appinfo>
                  </xsd:annotation>
          </xsd:element>
                                                 
                                                 
                                            </xsd:choice>
                        </xsd:sequence>
               </xsd:complexType>
            </xsd:element>
                                                                
            </xsd:sequence>
      </xsd:complexType>
   </xsd:element>


</xsd:schema>


While parsing below message I am getting the parsing error;

Quote:
Message: PHXGDCI200000200201903280055260200000007 7852149652365785 30220190328005526000000552668 0018521479632587412785412589654758 02


Quote:
Error: fatal: CTDP3002E: Unexpected data found at offset '255' after parsing completed. Data: '0x35...'.


I have set fixed length value also and discriminator also for using different transaction code like '302', '303' etc.
Back to top
View user's profile Send private message
timber
PostPosted: Mon Jul 22, 2019 1:42 am Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1012

You need to understand where the parser went wrong. The only way to do that is to read the DFDL trace. Have you done that yet?

Also...the error message says that the problem occurred at offset 255. But the message that you posted only has 126 bytes of data.
Back to top
View user's profile Send private message
mhasan23
PostPosted: Tue Jul 23, 2019 9:23 pm Post subject: Reply with quote

Novice

Joined: 12 Oct 2017
Posts: 19

@timber thanks for your response. I have resolve the issue by adding multiple sequence within choice and each sequence have discriminator for criteria"Message Type". Now each one works with their respective Message Type.

But I have noticed one thing if name is same like "AccountNumber" in two difference sequence it will give an error I don't understand why because sequence are difference.
Back to top
View user's profile Send private message
timber
PostPosted: Wed Jul 24, 2019 12:40 am Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1012

Glad it's working now.

Quote:
I have resolve the issue by adding multiple sequence within choice and each sequence have discriminator for criteria"Message Type". Now each one works with their respective Message Type.
I can't comment on whether that is the ideal solution. I still recommend that you look carefully at the DFDL trace (if you have not done so). Sometimes it can reveal unexpected details.

Quote:
But I have noticed one thing if name is same like "AccountNumber" in two difference sequence it will give an error I don't understand why because sequence are difference.
Probably the XML Schema rule 'Unique Particle Attribution'. Hard to say, because you did not quote the error.
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere Message Broker SupportDFDL Message Parsing with 'choice' tag
Jump to:



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
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.