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 for a repeating fixed length record

Post new topicReply to topic
DFDL for a repeating fixed length record View previous topic :: View next topic
Author Message
akashdwolf
PostPosted: Tue Sep 04, 2018 6:32 am Post subject: DFDL for a repeating fixed length record Reply with quote

Apprentice

Joined: 09 Feb 2017
Posts: 26
Location: Mumbai

Hi Friends,

I have made a DFDL for parse the below data which is working successfully:
OIL L 0000019900000XXX-PUT-3626 0010000 IS

DFDL:
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:recSepFieldsFmt="http://www.ibm.com/dfdl/RecordSeparatedFieldFormat">
    <xsd:import namespace="http://www.ibm.com/dfdl/RecordSeparatedFieldFormat" schemaLocation="../IBMdefined/RecordSeparatedFieldFormat.xsd"/>
    <xsd:annotation>
      <xsd:appinfo source="http://www.ogf.org/dfdl/">
         <dfdl:format encoding="{$dfdl:encoding}" escapeSchemeRef="" occursCountKind="implicit" ref="recSepFieldsFmt:RecordSeparatedFieldsFormat"/>
      </xsd:appinfo>
   </xsd:annotation>

<xsd:element dfdl:lengthKind="delimited"  dfdl:occursCountKind="implicit" ibmSchExtn:docRoot="true" name="field1">
<xsd:complexType>

<xsd:sequence dfdl:separator="" dfdl:sequenceKind="ordered" >

<xsd:element dfdl:length="4" dfdl:lengthKind="explicit" name="value1" type="xsd:string"/>
<xsd:element dfdl:length="2" dfdl:lengthKind="explicit" name="value2" type="xsd:string"/>
<xsd:element dfdl:length="8" dfdl:lengthKind="explicit" name="value3" type="xsd:string"/>
<xsd:element dfdl:length="3" dfdl:lengthKind="explicit" name="value4" type="xsd:string"/>
<xsd:element dfdl:length="2" dfdl:lengthKind="explicit" name="value5" type="xsd:string"/>
<xsd:element dfdl:length="15" dfdl:lengthKind="explicit" name="value6" type="xsd:string"/>
<xsd:element dfdl:length="3" dfdl:lengthKind="explicit" dfdl:textNumberPattern="#0" name="value7" type="xsd:integer"/>
<xsd:element dfdl:length="4" dfdl:lengthKind="explicit" dfdl:textNumberPattern="#0" name="value8" type="xsd:integer"/>
<xsd:element dfdl:length="18" dfdl:lengthKind="explicit" name="value9" type="xsd:string"/>
<xsd:element dfdl:length="2" dfdl:lengthKind="explicit" name="value10" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>

</xsd:element>

</xsd:schema>


This is a working DFDL.

Now the requirement is to parse multiple records so the new input request looks something like below having 4 records:
OIL L 0000019900000XXX-PUT-3626 0010000 ISOIL L 0000019900000XXX-PUT-3626 0010000 ISOIL L 0000019900000XXX-PUT-3626 0010000 IS

I am stuck here,Please help!!!
Back to top
View user's profile Send private message
timber
PostPosted: Tue Sep 04, 2018 6:44 am Post subject: Reply with quote

Sentinel

Joined: 25 Aug 2015
Posts: 868

Please don't post code/text without formatting it - there is a reason why those buttons are provided

Your structure currently looks like this:
Code:
field1
    value1
    value2
    ...
    value10


It needs to look like this:
Code:

message1
    record1 minOccurs="0" maxOccurs="unbounded"
        field1
        field2
        ...
        field10


Note that I have changed your element names to use standard terminology - most people don't refer to a complex structure as a 'field'. And 'value' is normally the value of an element, not its name.

Obviously, you can set minOccurs to 1 and maxOccurs to a fixed value if that's more appropriate.
Back to top
View user's profile Send private message
akashdwolf
PostPosted: Tue Sep 04, 2018 6:58 pm Post subject: Reply with quote

Apprentice

Joined: 09 Feb 2017
Posts: 26
Location: Mumbai

Hi Timber,

Thanks for the comments.I have made the changes that you suggested but it is giving error for multiple records.

Below is the new DFDL:


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:recSepFieldsFmt="http://www.ibm.com/dfdl/RecordSeparatedFieldFormat">
   <xsd:import namespace="http://www.ibm.com/dfdl/RecordSeparatedFieldFormat" schemaLocation="../IBMdefined/RecordSeparatedFieldFormat.xsd" />
   <xsd:annotation>
      <xsd:appinfo source="http://www.ogf.org/dfdl/">
         <dfdl:format encoding="{$dfdl:encoding}" escapeSchemeRef="" ref="recSepFieldsFmt:RecordSeparatedFieldsFormat" />
      </xsd:appinfo>
   </xsd:annotation>
   <xsd:element name="message" dfdl:lengthKind="implicit" ibmSchExtn:docRoot="true">
      <xsd:complexType>
         <xsd:sequence>
            <xsd:element name="record" ibmSchExtn:docRoot="true" dfdl:occursCountKind="implicit" maxOccurs="unbounded" minOccurs="0">
               <xsd:complexType>
                  <xsd:sequence dfdl:separator="" dfdl:sequenceKind="ordered">
                     <xsd:element dfdl:length="4" dfdl:lengthKind="explicit" name="field1" type="xsd:string" />
                     <xsd:element dfdl:length="2" dfdl:lengthKind="explicit" name="field2" type="xsd:string" />
                     <xsd:element dfdl:length="8" dfdl:lengthKind="explicit" name="field3" type="xsd:string" />
                     <xsd:element dfdl:length="3" dfdl:lengthKind="explicit" name="field4" type="xsd:string" />
                     <xsd:element dfdl:length="2" dfdl:lengthKind="explicit" name="field5" type="xsd:string" />
                     <xsd:element dfdl:length="15" dfdl:lengthKind="explicit" name="field6" type="xsd:string" />
                     <xsd:element dfdl:length="3" dfdl:lengthKind="explicit" dfdl:textNumberPattern="#0" name="field7" type="xsd:integer" />
                     <xsd:element dfdl:length="4" dfdl:lengthKind="explicit" dfdl:textNumberPattern="#0" name="field8" type="xsd:integer" />
                     <xsd:element dfdl:length="18" dfdl:lengthKind="explicit" name="field9" type="xsd:string" />
                     <xsd:element dfdl:length="2" dfdl:lengthKind="explicit" name="field10" type="xsd:string" />
                  </xsd:sequence>
               </xsd:complexType>
            </xsd:element>
         </xsd:sequence>
      </xsd:complexType>
   </xsd:element>
</xsd:schema>


Below is a working record for 1 string:
YYY L 0000019900000XXX-PUT-3626 001000000 IS

Below is a not working record:
YYY L 0000019900000XXX-PUT-3626 001000000 ISYYY L 0000019900000XXX-PUT-3626 001000000 IS

Below is the error:
Sep 5, 2018, 8:28:29 AM error: CTDP3058E: Separator ',' not found at offset '61' for sequence within element '/message[1]'.

Sep 5, 2018, 8:28:29 AM fatal: CTDP3058E: Separator ',' not found at offset '61' for sequence within element '/message[1]'.

Please suggest
Back to top
View user's profile Send private message
manojreddy524
PostPosted: Tue Sep 04, 2018 10:21 pm Post subject: Reply with quote

Newbie

Joined: 19 Apr 2016
Posts: 8

Hi Akash, following is the required schema in ur case. It will work for any no of records

Code:
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:csv="http://www.ibm.com/dfdl/CommaSeparatedFormat" 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">


    <xsd:import namespace="http://www.ibm.com/dfdl/CommaSeparatedFormat" schemaLocation="IBMdefined/CommaSeparatedFormat.xsd"/>
    <xsd:annotation>
      <xsd:appinfo source="http://www.ogf.org/dfdl/">
         <dfdl:format documentFinalTerminatorCanBeMissing="yes" encoding="{$dfdl:encoding}" escapeSchemeRef="csv:CSVEscapeScheme" ref="csv:CommaSeparatedFormat"/>
      </xsd:appinfo>
   </xsd:annotation>


   <xsd:element ibmSchExtn:docRoot="true" name="a">
      <xsd:complexType>
         <xsd:sequence dfdl:separator="">
            <xsd:element dfdl:occursCountKind="implicit" dfdl:terminator="%CR;%LF;%WSP*;" maxOccurs="unbounded" name="record">
               <xsd:complexType>
                  <xsd:sequence dfdl:separator="" dfdl:separatorSuppressionPolicy="trailingEmpty">
                     <xsd:element dfdl:length="4" dfdl:lengthKind="explicit" name="value1" type="xsd:string"/>
                     <xsd:element dfdl:length="2" dfdl:lengthKind="explicit" name="value2" type="xsd:string"/>
                     <xsd:element dfdl:length="8" dfdl:lengthKind="explicit" name="value3" type="xsd:string"/>
                     <xsd:element dfdl:length="3" dfdl:lengthKind="explicit" name="value4" type="xsd:string"/>
                     <xsd:element dfdl:length="2" dfdl:lengthKind="explicit" name="value5" type="xsd:string"/>
                     <xsd:element dfdl:length="15" dfdl:lengthKind="explicit" name="value6" type="xsd:string"/>
                     <xsd:element dfdl:length="3" dfdl:lengthKind="explicit" dfdl:textNumberPattern="#0" name="value7" type="xsd:integer"/>
                     <xsd:element dfdl:length="4" dfdl:lengthKind="explicit" name="value8" type="xsd:string"/>
                     <xsd:element dfdl:length="1" dfdl:lengthKind="explicit" name="value9" type="xsd:string"/> 
                  </xsd:sequence>
               </xsd:complexType>
            </xsd:element>            
         </xsd:sequence>
      </xsd:complexType>
   </xsd:element>


</xsd:schema>




tested rec file :

OIL L 0000019900000XXX-PUT-3626 0010000 IS
OIL L 0000019900000XXX-PUT-3626 0020000 IS
Code:
Back to top
View user's profile Send private message
manojreddy524
PostPosted: Fri Sep 07, 2018 1:29 am Post subject: Reply with quote

Newbie

Joined: 19 Apr 2016
Posts: 8

Code:

<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:csv="http://www.ibm.com/dfdl/CommaSeparatedFormat" 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">


    <xsd:import namespace="http://www.ibm.com/dfdl/CommaSeparatedFormat" schemaLocation="IBMdefined/CommaSeparatedFormat.xsd"/>
    <xsd:annotation>
      <xsd:appinfo source="http://www.ogf.org/dfdl/">
         <dfdl:format documentFinalTerminatorCanBeMissing="yes" encoding="{$dfdl:encoding}" escapeSchemeRef="csv:CSVEscapeScheme" ref="csv:CommaSeparatedFormat"/>
      </xsd:appinfo>
   </xsd:annotation>


   <xsd:element ibmSchExtn:docRoot="true" name="a">
      <xsd:complexType>
         <xsd:sequence dfdl:outputNewLine="%CR;%LF;" dfdl:separator="%CR;%LF;%WSP*;" dfdl:terminator="">
            <xsd:element dfdl:terminator="" maxOccurs="unbounded" name="Data">
               <xsd:complexType>
                  <xsd:sequence dfdl:separator="" dfdl:terminator="">
                     <xsd:element dfdl:length="4" dfdl:lengthKind="explicit" name="value1" type="xsd:string"/>
                     <xsd:element dfdl:length="2" dfdl:lengthKind="explicit" name="value2" type="xsd:string"/>
                     <xsd:element dfdl:length="8" dfdl:lengthKind="explicit" name="value3" type="xsd:string"/>
                     <xsd:element dfdl:length="3" dfdl:lengthKind="explicit" name="value4" type="xsd:string"/>
                     <xsd:element dfdl:length="2" dfdl:lengthKind="explicit" name="value5" type="xsd:string"/>
                     <xsd:element dfdl:length="15" dfdl:lengthKind="explicit" name="value6" type="xsd:string"/>
                     <xsd:element dfdl:length="3" dfdl:lengthKind="explicit" dfdl:textNumberPattern="#0" name="value7" type="xsd:integer"/>
                     <xsd:element dfdl:length="4" dfdl:lengthKind="explicit" name="value8" type="xsd:string"/>
                     <xsd:element dfdl:length="1" dfdl:lengthKind="explicit" dfdl:terminator="" name="value9" type="xsd:string"/> 
                                                                                              </xsd:sequence>
               </xsd:complexType>
            </xsd:element>            
                                                             </xsd:sequence>
      </xsd:complexType>
   </xsd:element>


</xsd:schema>



Input File :

OIL L 0000019900000XXX-PUT-3626 0010000 IS
OIL L 0000019900000XXX-PUT-3626 0020000 IS
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 for a repeating fixed length record
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.